I try to explain better the situation.
The variables are:
int punteggio;
CCLabelTTF *labelPunteggio;
Then in the init metod i print my score on the screen:
- (id)init {
if ((self = [super init])) {
// PUNTEGGIO
labelPunteggio = [CCLabelTTF labelWithString:@"0000" fontName:@"Marker Felt" fontSize:13];
[self addChild:labelPunteggio];
....
}
}
And this is the function to add score on Punteggio: for example, every time i kill a monster i add 10 point.
-(void)aggiungiPunti
{
punteggio = punteggio +0001;
[labelPunteggio setString:[NSString stringWithFormat:@"%d", punteggio]];
}
But now, i don't know how save the score when the player do game over. I'd want save this score, and then print the high score on the screen, i think about
-(void) setScore:(int)score
{
punteggio = highScore;
if (punteggio>highScore)
{
highScore = punteggio;
}
}
Thank you!