我有这个:
-(void)fadeBackground
{
ccColor4B color = {0,0,0,255};
CCLayerColor *fadeLayer = [CCLayerColor layerWithColor:color];
[self addChild:fadeLayer z:7];
fadeLayer.opacity = 0;
id fade = [CCFadeTo actionWithDuration:1.0f opacity:200];//200 for light blur
id calBlk = [CCCallBlock actionWithBlock:^{
//show pause screen buttons here
//[self showPauseMenu];
}];
id fadeBack = [CCFadeTo actionWithDuration:2.0f opacity:0];
id sequen = [CCSequence actions:fade, calBlk, fadeBack, nil];
[fadeLayer runAction:sequen];
}
如何在fadein发生时停止操作并在fadeBack发生时恢复它们?
答案 0 :(得分:2)
[[CCDirector sharedDirector] pause];
& [[CCDirector sharedDirector] resume];
将在所有Sprite / Layers或任何其他cocos2d节点中暂停和恢复调度程序和操作。
如果您想暂停/恢复特定CCLayer及其包含的子项
////for pausing
[myLayer pauseSchedulerAndActions];
for(CCNode *child in myLayer.children){
[child pauseSchedulerAndActions];
}
///for resuming
[myLayer resumeSchedulerAndActions];
for(CCNode *child in myLayer.children){
[child resumeSchedulerAndActions];
}
答案 1 :(得分:1)
要暂停,您可以使用此通话,需要为游戏中的每个菜单调用相同的内容。
[self pauseSchedulerAndActions];
[menu pauseSchedulerAndActions];
要恢复:
[self resumeSchedulerAndActions];
[menu pauseSchedulerAndActions];