gpt4 book ai didi

ios - 分数标签显示值覆盖

转载 作者:行者123 更新时间:2023-11-28 19:40:00 25 4
gpt4 key购买 nike

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

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];
}

最佳答案

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

-(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];

}

关于ios - 分数标签显示值覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34956475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com