观看视频广告后在屏幕上更新分数
Update score on screen after watching video ad
我有两个场景GameScene
和BonusScene
我用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];
}
我有两个场景GameScene
和BonusScene
我用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];
}