0
我在helloworld圖層中有按鈕。當我點擊按鈕時,我需要更換gmaelayer場景。但是當我點擊按鈕時,我得到了錯誤。'NSInvalidArgumentException',原因:' - [HelloWorldLayer starGame:]:無法識別的選擇器發送到實例0x96764d0'
代碼:
- (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]];
}
,並使其更明顯:你不小心寫了'starGame:',而不是'startGame:'。你只是錯過了一封信。 – 2013-05-07 05:57:50