Cocos2d-x 反复动画

//螺旋桨动画
    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)