Ios 如何设置CCProgressTimer精灵的动画?

Ios 如何设置CCProgressTimer精灵的动画?,ios,cocos2d-iphone,Ios,Cocos2d Iphone,有没有一种方法可以使CCProgressTimer精灵动画化? 我试过了,但没用:( if(timeCountdown只需更改精灵的颜色属性。或定期更改其可见状态。尝试以下代码: //[animation setLoops:1]; [progressTimer stopAllActions]; [progressTimer.sprite runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:anima

有没有一种方法可以使CCProgressTimer精灵动画化? 我试过了,但没用:(


if(timeCountdown只需更改精灵的颜色属性。或定期更改其可见状态。

尝试以下代码:

//[animation setLoops:1];
[progressTimer stopAllActions];
[progressTimer.sprite runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation]]];

我明白了。但是如何永远运行action?请检查我的新代码。谢谢。
if (timeCountdown <= 10) {
        int n = [progressTimer.sprite numberOfRunningActions];
        if (n == 0) {
            [time_bar removeFromParent];
            CCAnimation *animation = [[CCAnimation alloc] init];
            [animation addSpriteFrameWithFilename:@"time-bar.png"];
            [animation addSpriteFrameWithFilename:@"time-bar-white.png"];
            [animation setDelayPerUnit:0.02f];
            [animation setRestoreOriginalFrame:YES];
            id repeatAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation]];
            [time_bar runAction:repeatAction];
            [self addChild:time_bar];
        }
    }
    else {
        [time_bar stopAllActions];
        [time_bar setTexture:[[CCTextureCache sharedTextureCache] addImage:@"time-bar.png"]];


    }
//[animation setLoops:1];
[progressTimer stopAllActions];
[progressTimer.sprite runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:animation]]];