Update Label Value in Cocos2d(更新 Cocos2d 中的标签值)
问题描述
我正在 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 中的标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更新 Cocos2d 中的标签值


基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iOS4 创建后台定时器 2022-01-01