cocos2d-3.2 逐帧动画播放

cocos2d-3.2 逐帧动画播放,第1张

概述动画实现的基本流程: 1.定义向量保存动画的所有帧 Vector<SpriteFrame *> allframe; for(int i=1;i<10;i++) {  SpriteFrame * sf=SpriteFrame::create(                    StringUtils::format("run%d.png",i),                    Rect(

动画实现的基本流程:


1.定义向量保存动画的所有帧

Vector<SpriteFrame *> allframe;


for(int i=1;i<10;i++)

{

SpriteFrame * sf=SpriteFrame::create(

StringUtils::format("run%d.png",i),

Rect(0,w,h) );

allframe.pushBack(sf);

}

2.创建动画

Animation * animation01=Animation::createWithSpriteFrames(allframe);

animation01->setDelayPerUnity(0.3);

3.创建动作

Animate *animate01=Animate::create(animation01);

4.包装动作

Action * act=RepeatForEver::create(animate01);

5.让一个Sprite执行动作

Sprite * sp=Sprite::create();

sp->runAction(act);

总结

以上是内存溢出为你收集整理的cocos2d-3.2 逐帧动画播放全部内容,希望文章能够帮你解决cocos2d-3.2 逐帧动画播放所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1043827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存