Cocos2D - CCLabelTTF - Wait for End of Running Actions


simply, before I start new level of my game, I show countdown (using CCLabelTTF, Cocos2D).

I have this code:

[email protected]"New level";
[centerLevelLabel runAction:[CCFadeOut actionWithDuration:1]];

while (centerLevelLabel.numberOfRunningActions>0) {


[email protected]"3";
while (centerLevelLabel.numberOfRunningActions>0) {


[email protected]"2";
while (centerLevelLabel.numberOfRunningActions>0) {


[email protected]"1";
while (centerLevelLabel.numberOfRunningActions>0) {


//some code bellow

I want to show thist label and then I need continue with code bellow. Problem is, that UI is freezed and in first while block is running infinite loop. But i don`t kwon why, because when running actions is finished, numberOfRunningActions is zero.

Is there any other way, how could I wait for end of running actions and then continue?

Thank you

You could serialize the action by using a CCSequence and add the CCCallFuncN to execute some code after the original action completes.

id action1 = [CCFadeOut actionWithDuration:1];
id action2 = [CCCallFuncN actionWithTarget:self selector:@selector(finishedRunning)];
id sequenceActions = [CCSequence actions:action1, action2, nil]];

[centerLevelLabel runAction:sequenceActions];


   -(void) finishedRunning {
      // Do stuff after action finishes