gpt4 book ai didi

ios - 观看视频广告后在屏幕上更新分数

转载 作者:行者123 更新时间:2023-11-29 01:00:27 29 4
gpt4 key购买 nike

我有两个场景 GameSceneBonusScene我使用 NSUserDefaults 来保存中奖次数,一切正常,我添加视频奖励广告,观看后视频,你得到 5 分,这也有效,但屏幕上的分数更新只发生在你去不同的场景并返回时,但是当我使用 NSLog() 我看到更新发生了,但是我不知道如何在屏幕上实时进行。这是我得到的:

    losingCount=[scoreprefs integerForKey:@"losingCount"];
SKLabelNode *winsCoutnt = [SKLabelNode labelNodeWithFontNamed:@"ROTORcap Extended Bold"];
winsCoutnt.text =[NSString stringWithFormat:@"%ld",(long)losingCount];
winsCoutnt.position = CGPointMake(CGRectGetMidX(self.frame) + 100,(CGRectGetMidY(self.frame)) + self.frame.size.height/4 );
winsCoutnt.fontSize = 15.f;
[self addChild:winsCoutnt];



if([Chartboost hasRewardedVideo:@"NetworkVideo"] == YES) {

NSUserDefaults *scoreprefs = [NSUserDefaults standardUserDefaults];

losingCount =[scoreprefs integerForKey:@"losingCount"];
losingCount = losingCount +5;
[scoreprefs setInteger:losingCount forKey:@"losingCount"]; }

所以我的问题是如何在屏幕上实时更新场景中的乐谱,而不用去不同的场景再回来?

最佳答案

只需更新您更新 NSUserDefaults 的文本

    losingCount=[scoreprefs integerForKey:@"losingCount"];
SKLabelNode *winsCoutnt = [SKLabelNode labelNodeWithFontNamed:@"ROTORcap Extended Bold"];
winsCoutnt.text =[NSString stringWithFormat:@"%ld",(long)losingCount];
winsCoutnt.position = CGPointMake(CGRectGetMidX(self.frame) + 100,(CGRectGetMidY(self.frame)) + self.frame.size.height/4 );
winsCoutnt.fontSize = 15.f;
[self addChild:winsCoutnt];



if([Chartboost hasRewardedVideo:@"NetworkVideo"] == YES) {

NSUserDefaults *scoreprefs = [NSUserDefaults standardUserDefaults];

losingCount =[scoreprefs integerForKey:@"losingCount"];
losingCount = losingCount +5;
[scoreprefs setInteger:losingCount forKey:@"losingCount"];

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

关于ios - 观看视频广告后在屏幕上更新分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37059224/

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