我为得分的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];
答:connor
你应该为场景添加相应的标签,如果想用初始化的方法,可以编写:
当然,你的得分标签只是包括文本分数(text "score"),而不是实际的得分。如果想要表现出实际得分,需要将标签的形式设定为: