Здесь это может работать
В файле .h:
@interface HelloWorld : CCLayer {
int score;
CCLabelTTF *scoreLabel;
}
- (void)addPoint;
В файле .m:
В методе init:
//Set the score to zero.
score = 0;
//Create and add the score label as a child.
scoreLabel = [CCLabelTTF labelWithString:@"8" fontName:@"Marker Felt" fontSize:24];
scoreLabel.position = ccp(240, 160); //Middle of the screen...
[self addChild:scoreLabel z:1];
Где-то еще:
- (void)addPoint
{
score = score + 1; //I think: score++; will also work.
[scoreLabel setString:[NSString stringWithFormat:@"%@", score]];
}
Теперь просто позвоните: [self addPoint]; всякий раз, когда пользователь убивает врага.
Это должно сработать, скажите мне, если это не сработало, потому что я не проверял это.