我试图解释更好的情况。保存高分cocos2d
的变量是:
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;
}
}
谢谢!
xcode给我的错误...我不知道为什么.. – 2013-03-08 19:43:09
哪个错误?名称 – Guru 2013-03-09 04:50:04
错误是:行[[NSUserDefaults standardUserDefaults] synchronize]上的预期“]”; – 2013-03-09 19:03:44