CCSprite* sp = CCSprite::create("crop1.png");
sp->setPosition(ccp(170, 200));
addChild(sp);
CCAnimation* animation = CCAnimation::create();
animation->addSpriteFrameWithFileName("crop1.png");
animation->addSpriteFrameWithFileName("crop2.png");
animation->addSpriteFrameWithFileName("crop3.png");
animation->addSpriteFrameWithFileName("crop4.png");
animation->setDelayPerUnit(1.2); //必须设置否则不会动态播放
animation->setRestoreOriginalFrame(true); //是否返回第一帧
animation->setLoops(-1); //重复次数 -1无限循环
CCFiniteTimeAction* animate = CCAnimate::create(animation);
sp->runAction(animate);
cocos2d-x CCAnimation实现动画
最新推荐文章于 2020-08-06 17:06:04 发布