所以我編程的Xcode 3.2.4與cocos2d的遊戲,我做了一個名爲球員類。到目前爲止,它只有一個功能是什麼都不做。應用程序崩潰,每當空方法調用
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface Player : CCSprite {
}
-(void)leftButtonPressed;
@end
#import "Player.h"
@implementation Player
- (id)init{
if((self=[super init])){
self = [CCSprite spriteWithFile:@"playerPlane.png"];
}
return self;
}
-(void)leftButtonPressed{
}
@end `
每當我試圖從任何地方在控制檯
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CCSprite leftButtonPressed]: unrecognized selector sent to instance 0x6e4bb50'
我初始化播放器作爲另一個類的實例做 Player * thePlayer = [[Player alloc]init];
請幫忙!謝謝!!
「是在Xcode 3.2.4編程遊戲」 ...的是,三年前是什麼時候?只是開玩笑,但認真,即使你仍然在雪豹,你應該升級到至少4.2。 – LearnCocos2D