Reputation: 1698
I'm developing something for iOS with cocos2d. Now I have this CCLabelBMFont instance variable named scoreLabel.
scoreLabel = [CCLabelBMFont labelWithString:@"0" fntFile:@"bitmapfont.fnt"];
scoreLabel.position = CGPointMake(screenSize.width / 2, screenSize.height / 2);
scoreLabel.anchorPoint = CGPointMake(0.5f, 1.0f);
[self addChild:scoreLabel z:-1];
so far, so good. It works, but now I would like to update the label with another text containing the score.
score = currentTime;
[scoreLabel setString:[NSString stringWithFormat:@"%i", score]];
and this doesn't work. I set a breakpoint and score contains a value, but it just won't update the label. When I replace [NSString stringWithFormat:@"%i", score] with something like @"34234" it DOES work. So i'm quite confused.
Upvotes: 0
Views: 1179
Reputation: 1698
Oh, finally got it. I made a stupid mistake, the score value I was trying to convert was a float. So when I tried to cast it to a string with the %i, %d or %@ format the value was lost.
thanks for the reply anyway.
Upvotes: 0