-(void)test:(CCMenuItemSprite*)item
{
[item runAction:action];
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}
how do i make it so that item completes the action before the scene gets replaced? Thanks
You would do something like:
CCScene* sceneToRun = ...;
CCMenuItemSprite* item = ...;
id action = ...;
id changeSceneAction = [CCCallBlock actionWithBlock:^
{
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}];
id seqAction = [CCSequence actions:action, changeSceneAction, nil];
[item runAction:seqAction];
Assume the ... represents the creation of the item. If you are using cocos2d 3.0 you would do something like:
id changeSceneAction = [CCActionCallBlock actionWithBlock:^
{
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}];
id seqAction = [CCActionSequence actions:action, changeSceneAction, nil];
[item runAction:seqAction];
Hope this helps.