所以在使用Cocos2d的Objective-C中,我使用带有格式的NSMutableString将变量(得分)放入字符串中.我拿这个字符串并使用CCLabel将它放在屏幕上.
使用Cocos2D-x,我很难找到获得此结果的方法.一个简单的例子就是很棒.谢谢!
解决方法
@H_403_7@int score = 35; float time = 0.03; char* name = "Michael"; char text[256]; sprintf(text,"name is %s,time is %.2f,score is %d",name,time,score); CCLabelTTF* label = CCLabelTTF::labelWithString(text,"Arial",20); this->addChild(label);