1,帧动画:
原文链接:https://www.f2er.com/cocos2dx/343381.html
Vector<SpriteFrame*> allsf;
for(int i=0;i<4;++i)
{
SpriteFrame * sf=SpriteFrame::create(
"baozha.png"
,Rect(i*
59
,
0
,216)">59
));
allsf.pushBack(sf);
}
Animation * ani=Animation::createWithSpriteFrames(allf);
ani->setDelayPerUnit( 0.3 );
Animate * ane=Animate::create(ani);
ani->setDelayPerUnit( 0.3 );
Animate * ane=Animate::create(ani);
//ane是一个可以播放的帧动画
————————————————————
//让动画循环播放
Action *act=RepterForever::
create(ane);
//循环播放的简写
Sprite *sp=Sprite::create();
sp->runAction(RepterForever::create(Animate::create(ani)))
帧动画与动画缓存:
AnimationCache::getInstance()->addAnimation(ani,”动画1别名”);
AnimationCache::getInstance()->getAnimation(“动画1别名”);
RepterForever::create(“这是对一个动作的包裹,实现动作循环播放”);
Animate::create(“这是对一个可播放动作的包裹”);
sp->runAction(RepterForever::create(Animate::create(AnimationCache::getInstance()->getAnimation(“动画1别名"))));