我正在尝试制作应用,目前我正在尝试将数据分成不同的文件。
我将从主类(ArcherClass)和播放器类中提供一些代码。 这是玩家类:
Player.h_的 _ __ _ __ _ __ _ __ _ < / EM> __ _ __ _ __
@interface Player:CCLayer{
CCSprite *_head;
}
@property (nonatomic, retain) CCSprite *head;
-(void)setHead:(CCSprite *)head;
+(id)player;
@end
Player.m_的 _ __ _ __ _ __ _ __ _ < / EM> __ _ __ _ __
@implementation Player
@synthesize head = _head;
+(id)player{
Player *playerSprite = nil;
return playerSprite;
}
-(void)setHead:(CCSprite *)head{
_head = [CCSprite spriteWithFile:@"head.png"];
}
@end
ArcherClass.m_的 _ __ _ __ _ __ _ __ _ < / EM> __ _ __ _ __
#import "ArcherClass.h"
#import "cocos2d.h"
#import "Player.h"
@implementation ArcherClass
//skip some stuff...
+(id) scene{
CCScene *scene = [CCscene node];
CCLayer* layer = [ArcherClass node];
[scene addChild:layer];
return scene;
}
-(id) init{
if(self = [super init]{
self.isTouchEnabled = YES;
}
Player *player = [[Player alloc]init];
CCSprite *bob = player.head;
bob.position = ccp(250,250);
//There are layers in this class, so this may be a problem
}
我有应用程序和工作,一切都工作,因为一切都是ArcherClass的本地。没有其他课程。现在我正在努力为所有事情制作单独的课程,但我遇到了问题。我该如何解决这个问题?