CStreel
CStreel

Reputation: 2642

My Cocos2d CCMenu won't responding to touch

Hi there when my game reaches it's Game Over Scene i have a button to return to the Main menu and for some reason this has stopped working

Here is the code that leads to my Game Over Scene:

[[CCDirector sharedDirector] pause];
[[CCDirector sharedDirector] replaceScene:[ResultsScreen node]];

In my Init function for Game Over

....
mainMenu = [CCMenuItemImage itemFromNormalImage:@"MainMenu.png" selectedImage:@"MainMenuClick.png" target:self selector:@selector(Menu:)];
[mainMenu setAnchorPoint:ccp(0.0f, 0.0f)];
menu = [[CCMenu menuWithItems:mainMenu, nil] retain];
menu.isTouchEnabled = YES;
[menu setPosition:ccp(75, 80)];
[menu setAnchorPoint:ccp(0, 0)];
[self addChild:menu z:Z_INTERACTION];
....

My Selector Function for the button

- (void) Menu:(id)sender
{
    NSLog(@"Exit to MainMenu");
    [[CCDirector sharedDirector] replaceScene:[MainMenu node]];
}

Now I've compared this with my other code, all my other buttons are working, the only difference is that is that i am specifying a 'z' value.

Any help would be very much appreciated

Update: Ran a quick check with Leaks and Allocations and nothing seems to be an issue

Upvotes: 2

Views: 669

Answers (1)

CStreel
CStreel

Reputation: 2642

I found my Issue in my - (void) onEnter {}

I wasn't calling [super onEnter];

Upvotes: 5

Related Questions