0

I have this:

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

}

How do I stop the actions while the fadein occurs and resume them when the fadeBack occurs?

Guru
  • 21,652
  • 10
  • 63
  • 102
marciokoko
  • 4,988
  • 8
  • 51
  • 91

2 Answers2

2

[[CCDirector sharedDirector] pause]; & [[CCDirector sharedDirector] resume]; will pause and resume the schedulers and actions throughout all the Sprites/Layers or any other cocos2d Nodes.

If you want to pause/resume a particular CCLayer along with children its containing,

////for pausing
[myLayer pauseSchedulerAndActions];
for(CCNode *child in myLayer.children){
[child pauseSchedulerAndActions];
}

///for resuming
[myLayer resumeSchedulerAndActions];
for(CCNode *child in myLayer.children){
[child resumeSchedulerAndActions];
}
IronMan
  • 1,505
  • 1
  • 12
  • 17
1

To pause, you can use this call, need to call same for each menu in game.

   [self  pauseSchedulerAndActions];
   [menu  pauseSchedulerAndActions];

To resume:

  [self resumeSchedulerAndActions];
  [menu  pauseSchedulerAndActions];
Guru
  • 21,652
  • 10
  • 63
  • 102