//螺旋桨动画
airscrew=CCSprite::create();
CCArray *animFrame=CCArray::createWithCapacity(3);
for (int i=1; i<=3; i++) {
char str[100]={0};
sprintf(str,"airscrew0%d.png",i);
CCSpriteFrame *frame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str);
CCAnimationFrame *pAnimationFrame = new CCAnimationFrame();
pAnimationFrame->initWithSpriteFrame(frame, 0.5f,NULL);
animFrame->addObject(pAnimationFrame);
}
CCAnimation *panimation=CCAnimation::create(animFrame,0.5f);
animFrame->removeAllObjects();
CCRepeatForever *pRepeatForever = CCRepeatForever::create(CCAnimate::create(panimation));
CCSpriteFrame *frame1=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("airscrew01.png");
airscrew->setDisplayFrame(frame1);
airscrew->setPositionY(30);
addChild(airscrew);
airscrew->runAction(pRepeatForever);
Cocos2d-x 反复动画
最新推荐文章于 2022-03-05 09:43:42 发布