我在 helloworld 层中有按钮。当我单击按钮时,我需要替换 gmaelayer 场景。但是当我点击按钮时,我得到了错误。
代码:
- (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]];
}