Delay changes in CCAnimation

I would like to know how can I change the delay in CCAnimation?

_monstrAnim = [CCAnimation animationWithFrames:monstrAnimFrames delay:0.1f];
                self.monstr = [CCSprite spriteWithSpriteFrameName: [NSString stringWithFormat:@"monstr_%d_1.png", currentLevel]]; 
                self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:_monstrAnim restoreOriginalFrame:NO]];
                [self.monstr runAction:self.walkAction];
                [monstrSpriteSheet addChild:self.monstr z:1];

      

this works fine, but i have to change the FPS speed and i do ...

            [self.monstr stopAllActions];
            [self.monstr runAction:self.walkAction];
            [self.monstrAnim setDelay:1];

      

but nothing happened ...

+3


source to share


1 answer


Stop your walkAction, then change the animation delay, then re-create the action and run it again. If you look at the CCAnimate code throw, you can see that the interframe delay from the CCAnimation object is only used during the creation of the action. So this code

[self.monstr stopAllActions];
[self.monstrAnim setDelay:1.f];
self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:_monstrAnim restoreOriginalFrame:NO]];
[self.monstr runAction:self.walkAction];

      



will do the trick.

+5


source







All Articles