0
我正在为iOS和cocos2d开发一些东西。现在我有了名为scoreLabel的CCLabelBMFont实例变量。CCLabelBMFont setString似乎不适用于格式化字符串
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];
到目前为止,这么好。它的作品,但现在我想用另一个包含分数的文本更新标签。
score = currentTime;
[scoreLabel setString:[NSString stringWithFormat:@"%i", score]];
并且这不起作用。我设置了一个断点,分数包含一个值,但它不会更新标签。当我用@“34234”代替[NSString stringWithFormat:@“%i”,score]时,它确实起作用。所以我很困惑。