0
我試圖從我的主圖層中將得分傳遞給根據所述得分初始化的我的一個CCSprite。當我用這個初始化我的CCSprite時:用Cocos2d中的對象初始化CCSprite
//Main Layer
Platform *platform = [[Platform alloc] initWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"platform.png"] withScore:score];
//CCSprite Layer
-(id) initWithSpriteFrame:(CCSpriteFrame*)spriteFrame withScore:(int)initScore {
if((self=[super init])) {
...
}
}
我得到一個沒有CCSprite紋理的得分;
隨後,當我初始化這個:
//Main Layer
Platform *platform = [[Platform alloc]initWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache]spriteFrameByName:@"platform.png"]];
[platform setScore:score];
//CCSprite Layer
@property (readwrite) int score;
@synthesize score;
-(id) init {
if((self=[super init])) {
...
}
}
我得到一個CCSprite紋理都沒有分(這是0)。什麼是一個人要做的?
謝謝。完美的作品。 –