Note that there are some explanatory texts on larger screens.

plurals
  1. PObuttons not working in pause screen in cocos2d
    primarykey
    data
    text
    <p>Hello I am making a pause screen for my cocos2d game. I have 3 buttons: the resume button, the retry button, and the options button. None of them are responding to touch and doing what they are supposed to do. When the pause screen is pulled up, all of my actions are paused with this code:</p> <pre><code>[self pauseSchedulerAndActions]; [[CCDirector sharedDirector]pause]; [[CCDirector sharedDirector] replaceScene:[CCTransitionScene transitionWithDuration:1.0 scene:[PauseMenu scene]]]; </code></pre> <p>This is the code for my pause menu. I want to know why the buttons in the pause screen are not responding to touch and if the resume button and retry button code are correct in what I am trying to do. For the resume button I just want the pause menu layer to disappear and then the CCActions need to resume. For my retry button I just want to have the game restart by calling the GameScene layer which starts the game. Here is the code:</p> <pre><code>-(id)init{ if((self = [super init])){ CGSize size = [[CCDirector sharedDirector]winSize]; screenWidth = size.width; screenHeight = size.height; resumeButton = @"resume.png"; retryButton = @"retry.png"; optionsButton = @"optionspause.png"; pausedLabel = [CCSprite spriteWithFile:@"paused.png"]; pausedLabel.position = ccp(screenWidth/2, screenHeight/1.5); [self addChild:pausedLabel z:0]; [self makeTheMenu]; } return self; } -(void)makeTheMenu{ CCMenuItem* theResumeButton; CCMenuItem* theRetryButton; CCMenuItem* theOptionsButton; theResumeButton = [CCMenuItemImage itemWithNormalImage:resumeButton selectedImage:resumeButton target:self selector:@selector(resumeTheGame)]; theResumeButton.scale = 2; theRetryButton = [CCMenuItemImage itemWithNormalImage:retryButton selectedImage:retryButton target:self selector:@selector(retryTheGame)]; theRetryButton.scale = 2; theOptionsButton = [CCMenuItemImage itemWithNormalImage:optionsButton selectedImage:optionsButton target:self selector:@selector(optionsMenu)]; theOptionsButton.scale = 2; thePauseMenu = [CCMenu menuWithItems:theResumeButton, theRetryButton, theOptionsButton, nil]; thePauseMenu.position = ccp(screenWidth/2, screenHeight/2 - 100); [thePauseMenu alignItemsHorizontallyWithPadding:20]; [self addChild:thePauseMenu z:1]; } -(void)resumeTheGame{ [self resumeSchedulerAndActions]; [[CCDirector sharedDirector]resume]; [thePauseMenu removeFromParentAndCleanup:YES]; } -(void)retryTheGame{ [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameScene scene] withColor:ccBLACK]]; } -(void)optionsMenu{ CCLOG(@"options"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload