分数标签节点在第一轮后消失

Score label node disappears after first round

我不知道为什么,但是分数标签节点在第一个 round.I 有两个分数之后消失了,一个是人类的,另一个是计算机的:

-(void)scoreCount{ 
if(scoreLabel == nil){

    NSString* scoretxt =[NSString stringWithFormat:@"0"];
    [scoreLabel setText:scoretxt];

    scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"ROTORcapExtendedBold"];
    scoreLabel.fontSize = 65.f;
    scoreLabel.fontColor = [UIColor grayColor];
    scoreLabel.position =  CGPointMake(CGRectGetMidX(self.frame)/2,CGRectGetMaxY(self.frame)-70);
    scoreLabel.zPosition = -1;
    [self addChild:scoreLabel];
}

scoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score];


if(scoreLabelCom == nil){

    NSString* scoretxtcom =[NSString stringWithFormat:@"0"];
    [scoreLabelCom setText:scoretxtcom];

    scoreLabelCom = [SKLabelNode labelNodeWithFontNamed:@"ROTORcapExtendedBold"];
    scoreLabelCom.fontSize = 65.f;
    scoreLabelCom.fontColor = [UIColor grayColor];
    scoreLabelCom.position =  CGPointMake(CGRectGetMidX(self.frame)+(CGRectGetMidX(self.frame)/2),CGRectGetMaxY(self.frame)-70);
    scoreLabelCom.zPosition = -1;
    [self addChild:scoreLabelCom];
}

scoreLabelCom.text = [NSString stringWithFormat:@"%ld",(long)scoreCom];    
 }

每次有人得分时都会调用此方法,我输入

-(void)update:(CFTimeInterval)currentTime {
 [self scoreCount];
 }

因为,如果没有它,scoreCount 不会显示 0 分,而只会在第一分之后显示,但是,当新一轮开始时,ScoreCout 根本不会显示。 我该如何更正?为什么会这样?

(long)score(long)scoreCom 您现在可以为其增值。

score = score + 1; //Before add to nsstring
scoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score];

scoreCom = scoreCom + 1;//Before add to nsstring
scoreLabelCom.text = [NSString stringWithFormat:@"%ld",(long)scoreCom];

嗯,我不知道它有多好,但我在 didBeginContact 游戏结束时添加了 scoreLabel = nilscoreLabelCom = nil,现在可以使用了。