animationcocos2d-iphonerepeatccaction

Repeat CCAction Certain Number of Times?


In Cocos2D 2.x, I am doing runAction to do some animations in my game. It is working great but I want the animation to repeat a certain number of times.

So pretty much my pseudo-code is this:

CCSequence... action1, action2
[sprite runAction:theSequence];

So I just want to repeat the action for (lets say 3 times), how would I do this? I do not see any API to do this but maybe I am just not seeing something. If anyone knows how to do this and could share the information that would be great!

Thanks!


Solution

  • You can use CCRepeat to repeat an action a number of times:

    id repeatAction = [CCRepeat actionWithAction:theSequence times:3];
    [sprite runAction:repeatAction];