我为得分的int设置为:
int score=0;
我知道如何设置增加得分标签,但不太清楚怎样把它展示出来:
在我使用的代码中,但我觉得下述代码肯定存在问题:
CCLabelTTF *scorelabel = [CCLabelTTF labelWithString:@"score" fontName:@"Verdana-Bold" fontSize:18.0f];
int score=0;
CCLabelTTF *scorelabel = [CCLabelTTF labelWithString:@"score" fontName:@"Verdana-Bold" fontSize:18.0f];
[self addChild:scorelabel];<pre><code>有谁能帮我解决下这个问题吗?
我现在用的代码是:
</code></pre>int score=0;
CCLabelTTF *scorelabel = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"score: %d",score] fontName:@"Verdana-Bold" fontSize:18.0f]; **The warning**
scorelabel.positionType = CCPositionTypeNormalized;
scorelabel.position = ccp(0.0f, 0.0f);
[self addChild:scorelabel];<pre><code>backButton
</code></pre>CCButton *backButton = [CCButton buttonWithTitle:@"[ Menu ]" fontName:@"Verdana-Bold" fontSize:18.0f];
backButton.positionType = CCPositionTypeNormalized;
backButton.position = ccp(0.85f, 0.95f); // Top Right of screen
[backButton setTarget:self selector:@selector(onBackClicked:)];
[self addChild:backButton];
你应该为场景添加相应的标签,如果想用初始化的方法,可以编写:
[self addChild:scorelabel];
当然,你的得分标签只是包括文本分数(text "score"),而不是实际的得分。如果想要表现出实际得分,需要将标签的形式设定为:
CCLabelTTF *scorelabel = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"score: %d",score] fontName:@"Verdana-Bold" fontSize:18.0f];
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。