-(void)test:(CCMenuItemSprite*)item
{
[item runAction:action];
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}
如何让它在场景被替换之前完成动作? 感谢
答案 0 :(得分:0)
您可以这样做:
CCScene* sceneToRun = ...;
CCMenuItemSprite* item = ...;
id action = ...;
id changeSceneAction = [CCCallBlock actionWithBlock:^
{
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}];
id seqAction = [CCSequence actions:action, changeSceneAction, nil];
[item runAction:seqAction];
假设...代表项目的创建。如果你使用cocos2d 3.0,你会做类似的事情:
id changeSceneAction = [CCActionCallBlock actionWithBlock:^
{
[[CCDirector sharedDirector] replaceScene:sceneToRun];
}];
id seqAction = [CCActionSequence actions:action, changeSceneAction, nil];
[item runAction:seqAction];
希望这有帮助。