分数标签显示值覆盖 [英] score label display value overwrites

查看:43
本文介绍了分数标签显示值覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

THE 分数更新时,新的分数值标签会覆盖旧的显示值,因为这个分数是不可读的,如何更新新分数?这是我得到的:

When THE score updates, a new score value label overwrites old one on the display, because of this score is just unreadable, how to update new score? here what i got:

SKLabelNode *ScoreLabel;
NSInteger score = 0;
-----------------------------
-(void)Scoring{
score = score +1;
ScoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
ScoreLabel.position = CGPointMake(CGRectGetMidX(self.frame), 960);
ScoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score];
[self addChild:ScoreLabel];
}

推荐答案

每次乐谱更改时,您都会在顶部添加一个新标签.像这样更改代码:

You are adding every time the score changes a new label on top. Change the code like this:

-(void)Scoring{
  score = score +1;
  if (ScoreLabel == nil) {
    ScoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"];
    ScoreLabel.position = CGPointMake(CGRectGetMidX(self.frame), 960);
    [self addChild:ScoreLabel];
  }
  ScoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score];

}

这篇关于分数标签显示值覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆