I have a scene called CongratsScene which is loaded something like this:
[[CCDirector sharedDirector] replaceScene:[CCFlipAngularTransition transitionWithDuration:0.8f scene:[CongratsScene scene]]];
For some reason I am not able to add the menu to the scene. Here is the code:
+(id) scene
{
CCScene *scene = [CCScene node];
CongratsScene *layer = [CongratsScene node];
CCSprite *background = [CCSprite spriteWithFile:@"congratsscene.png"];
background.anchorPoint = CGPointMake(0,0);
[layer addChild:background];
[scene addChild:layer];
return scene;
}
-(void) restartGame:(CCMenuItem *) item
{
}
-(id)init
{
if( (self=[super init] ))
{
NSLog(@"init congrats fired!");
// add the restart game button
CCMenuItemImage *restartMenuItem =[CCMenuItemImage itemFromNormalImage:@"restartbutton.png"
selectedImage: @"restartbutton.png"
target:self
selector:@selector(restartGame:)];
CCMenu *menu = [CCMenu menuWithItems:restartMenuItem,nil];
menu.position = ccp(50,50);
[self addChild:menu];
}
return self;
}
UPDATE 1:
In the output window I am getting:
Unable to access variable "restartMenuItem"
UPDATE 2:
I solved my problem by changing the name of the menuItem variable and now it is working again. Not sure what was the main reason!