
2.x
//第二个参数表示显示区域的x,y,wIDth,height frame0=SpriteFrame::createWithTexture(this->getTexture(),Rect(237.5*0,237.5,191)); frame1=SpriteFrame::createWithTexture(this->getTexture(),Rect(237.5*1,191)); frame2=SpriteFrame::createWithTexture(this->getTexture(),Rect(237.5*2,191)); frame3=SpriteFrame::createWithTexture(this->getTexture(),Rect(237.5*3,191)); Array *animFrames=Array::create(); animFrames->addobject(frame0); animFrames->addobject(frame1); animFrames->addobject(frame2); animFrames->addobject(frame3); //根据4幅帧生成CCAnimation对象 Animation *animation = Animation::createWithSpriteFrames(animFrames); //根据动画模板创建动画 animation->setDelayPerUnit(0.2f); //animFrames->release(); Animate *animate=Animate::create(animation);
3.x
Vector<SpriteFrame*> frameVec; SpriteFrame* frame = NulL; //用纹理创建4幅帧动画 SpriteFrame *frame0,*frame1,*frame2,*frame3; //第二个参数表示显示区域的x,191)); frameVec.pushBack(frame0); frameVec.pushBack(frame1); frameVec.pushBack(frame2); frameVec.pushBack(frame3); //根据4幅帧生成CCAnimation对象 Animation *animation = Animation::createWithSpriteFrames(frameVec); //根据动画模板创建动画 animation->setDelayPerUnit(0.2f); //animFrames->release(); Animate *animate=Animate::create(animation); return animate;总结
以上是内存溢出为你收集整理的cocos2d-x-2.x与3.x帧动画实现方式的改变全部内容,希望文章能够帮你解决cocos2d-x-2.x与3.x帧动画实现方式的改变所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)