0

我有这个:

-(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];

}

如何在发生淡入时停止动作并在发生淡入时恢复它们?

4

2 回答 2

2

[[CCDirector sharedDirector] pause];& [[CCDirector sharedDirector] resume];将暂停和恢复所有 Sprites/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];
}
于 2013-06-22T06:38:07.753 回答
1

要暂停,您可以使用此调用,需要为游戏中的每个菜单调用相同的。

   [self  pauseSchedulerAndActions];
   [menu  pauseSchedulerAndActions];

恢复:

  [self resumeSchedulerAndActions];
  [menu  pauseSchedulerAndActions];
于 2013-05-18T04:51:23.823 回答