0
我試圖解釋更好的情況。打印得分和高分
的變量是:
int punteggio;
CCLabelTTF *labelPunteggio;
然後在init梅託德打印我的成績在屏幕上:
- (id)init {
if ((self = [super init])) {
// PUNTEGGIO
labelPunteggio = [CCLabelTTF labelWithString:@"0000" fontName:@"Marker Felt" fontSize:13];
[self addChild:labelPunteggio];
....
}
}
這是添加在Punteggio得分的功能:例如,每時間我殺了一個怪物,我加了10分。
-(void)aggiungiPunti
{
punteggio = punteggio +0001;
[labelPunteggio setString:[NSString stringWithFormat:@"%d", punteggio]];
}
但現在,我不知道當玩家做遊戲時如何保存分數。 我願意保存這個分數,然後打印高分屏幕上, 我想
-(void) setScore:(int)score
{
punteggio = highScore;
if (punteggio>highScore)
{
highScore = punteggio;
}
}
謝謝!
謝謝你!我嘗試但不起作用... 我打印在init metod像這樣labelScore = [CCLabelTTF labelWithString:@「0000」fontName:@「Marker Felt」fontSize:13]; [self addChild:labelScore]; labelhighScore = [CCLabelTTF labelWithString:@「0」fontName:@「Marker Felt」fontSize:13]; [self addChild:labelhighScore]; 得分變化但高分始終爲0。 – 2013-03-09 13:18:50