だから私はcocos2dを使ってXcode3.2.4でゲームをプログラミングしていて、playerという名前のクラスを作りました。今のところ、それは何もしない1つの機能しか持っていません。
#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 `
どこからでもleftButtonPressedを呼び出そうとすると、コンソールでアプリ全体がクラッシュします
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CCSprite leftButtonPressed]: unrecognized selector sent to instance 0x6e4bb50'
プレーヤーを別のクラスのインスタンスとして初期化するには、
Player * thePlayer = [[Player alloc]init];
助けてください!ありがとう!!