I have button in helloworld layer. When i click the button i need to replace gmaelayer scene. But when i click button i got error.
code:
- (id) init
{
if ((self = [super initWithColor:ccc4(255,255,255,255)])) {
CGSize winSize0 = [[CCDirector sharedDirector] winSize];
CCMenuItem *starMenuItem = [CCMenuItemImage
itemFromNormalImage:@"player.png" selectedImage:@"player.png"
target:self selector:@selector(starGame:)];
CCMenu *starMenu = [CCMenu menuWithItems:starMenuItem,nil];
starMenu.position = ccp(winSize0.width/2 , 25);
[starMenu alignItemsHorizontally];
[self addChild:starMenu];
}
return self;
}
-(void)startGame:(id)sender{
[[CCDirector sharedDirector] replaceScene:[GameLayer scene]];
}
You selector method is wrong.
CCMenuItem *starMenuItem = [CCMenuItemImage
itemFromNormalImage:@"player.png" selectedImage:@"player.png"
target:self selector:@selector(starGame:)];
Instead of
CCMenuItem *starMenuItem = [CCMenuItemImage
itemFromNormalImage:@"player.png" selectedImage:@"player.png"
target:self selector:@selector(startGame:)];