问题描述
我正在 cocos2d 中制作游戏,在更新分数时,旧的分数值会出现在标签上,而新的值会被覆盖.我正在使用以下代码来显示分数,
I am making a game in cocos2d , In that while updating score the old score values get on the label and the new value get overwritten. I m using following code to display the score,
LblScore = [CCLabel labelWithString:[NSString stringWithFormat:@"%d",score]
dimensions:CGSizeMake(100, 300)
alignment:UITextAlignmentCenter
fontName:@"Arial"
fontSize:32.0];
因为这个分数值没有显示出来,所有的东西都堆积起来了,如果有人知道如何更新新分数?
Because of this the score value are not shown and all things get massed up, If any one having idea how to update new score?
推荐答案
我的问题的解决方案是,我必须在 -(id)init 方法中定义标签声明,在任何地方提供的值上不会覆盖值.
The Solution for my problem is , I must have to define the label declaration in the -(id)init method, there on the value provided from any where there will be no overwriting of the values.
我已经尝试过了,它正在工作,但仍然感谢所有为我提供帮助的人
I've tried it and it's working, But still thanks to all who provided me a help
这篇关于更新 Cocos2d 中的标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!