0

I am trying to make my pause screen in my game. I am using the framework Cocos2d V3 RC4 in IOS and XCODE and SpriteBuilder. I read a lot of post and i think that i have two aproachs posible: 1º Push a total scene foward the main scene. (THIS WORK FINE TO ME) In the MAIN SCENE i call this to pause the game

CCScene *pausa = [CCBReader loadAsScene:@"Pausa"];
[[CCDirector sharedDirector] pushScene:pausa];

and then in the Pause class i call this to pop the pause scene and take back the Main scene:

[[CCDirector sharedDirector] popScene];

2º Take a CNode in front of the MAIN SCENE, making it with transparency, opaque, and disableing the main scene touch, animations, actions, etc… (THIS DOESN’t WORK FOR ME AND I WHANT THIS !!!) I doit in this way:

In the main Scene:

CCScene *pausa = [CCBReader loadAsScene:@"Pausa"];
[self addChild:pausa];

AND I TRY with ALL THIS METHODS:

//    [self unscheduleAllSelectors];
//    [self stopAllActions];
//    [self setPaused:TRUE];
//    [self setUserInteractionEnabled:FALSE];

The node is added but Have not Touch exclusively… The Node that is behind I can touch it… I try olso with :

[[CCDirector sharedDirector] pushScene:pausa];

(in the main scene) with result obviosly bad, and i try with

[self setExclusiveTouch:TRUE]; 

in the pause didLoadFromCCB method but also I cant make it have a Exclusive touch. i Can STILLPRESS buttons and sprites from the back Node…

What I am doing Wrong, And how is the correct code/aproach tu use to handle a pause node like I want for method 2??

Resuming... I only want a Modal Window... (like in zk framework, in java, the Window (CNode in Cocos2d) come in front and the background keep disabled and in grey)

Thanks for read and hope someone can help

2 Answers 2

1

Here is my implementation from a game that I am doing

- (void) pauseGame
{
    CCLOG(@"Pause game");
    _contentNode.paused = YES;
    _contentNode.userInteractionEnabled = NO;

    _gamePausedNode = (GamePausedNode *)[self loadCCBWithNameAndPositionInCenter:@"PausedNode"];

    [self addChild:_gamePausedNode];
}

gamePausedGame is a CCNode, but it could be CCSprite as well. It is not actually a CCScene, nor is it loaded by one because a modal view like this is not really a scene.

You usually want to group the CCNode objects together in one CCNode like my _contentNode so you can pause them with one click.

Update : I have edited the code to the bare minimals

4
  • Ey Tibor !! Thanks for reply my question. It's making me crazy... the method "presentMenuView" it's coded by you? Can You show it to me?? I Need to know how you add the Pause node to the main Scene, because I think that i am adding badly...
    – Joaquin
    Mar 26, 2014 at 11:54
  • Hello, I have updated the code for you and simplified it to the bare minimals. If this is not working you must have some other problem in your code. Bonne chance! Mar 27, 2014 at 14:25
  • Ahhhhhha!!!! You load the PAUSE CNODE like a specific class "GamePausedNode" i was doing something wrong there. But I don't find the method "loadCCBWithNameAndPositionInCenter" in my CCSCENE Gameplay class... It's yours that method?? that method is the same as [CCBReader load:@"Pausa"] ??? Thanks for answering me.
    – Joaquin
    Mar 28, 2014 at 15:26
  • Oh again sorry. It is just load, and then I set the position so that it is in the center of the screen. Mar 28, 2014 at 16:03
1

CCPhysicsNode *_physics;

_physics.paused = true;// It will pause your game but not actions.

_physics.paused = false;// It will resume your spinning and falling of sprites while button is pressable like during pause game.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.