Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing a simple cocos2d game in which I want to animate two CCSprites simultaneously, and for this purpose I simply set CCActions on respective `CCSprite's as follows.

[first runAction:[CCMoveTo actionWithDuration:1 position:secondPosition]];
[second runAction:[CCMoveTo actionWithDuration:1 position:firstPosition]];

Now I want to wait till the animations are complete, so I can perform the next step. How should I wait for these animations to finish?

There are actually two method calls, the first one animates the objects via the code above and second call does the other animation.

I need to delay the second method call until the animations in first are complete. (I would not like to use CCCallFunc blocks as I want to call the second method from the same caller as the first one.

share|improve this question

Try with a CCSequence action, here is the doc

Something like

[CCSequence actionsWithArray:first,second,finishCallFunc,nil]
share|improve this answer
I have multiple sprites with different CCSequences, how would I know when all CCSequences end ? – tGilani Nov 1 '12 at 4:17
CCNode has a numberOfRunningActions property. Maybe you can check for each sprite when all have 0 running actions. – Setrio Nov 1 '12 at 11:10

You could use CCDelayTime to add a pause in the sequence

id delay = [CCDelayTime actionWithDuration:1];

Then just add this to your sequence.

share|improve this answer

Have a flag if animations are running( simultaneousSpriteActionsAreRunning ). Set to true when the animations start.

In the update method of your main game loop check if each sprite has running actions using numberOfRunningActions.


     [self checkIfSpriteActionsHaveFinished];

    if( simultaneousSpriteActionsAreRunning 
        && sprite1.numberOfRunningActions == 0 
        && sprite1.numberOfRunningActions == 0 )
        //do stuff
        simultaneousSpriteActionsAreRunning = false; 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.