gpt4 book ai didi

ios - Xcode-提交分数到GameCenter

转载 作者:行者123 更新时间:2023-11-28 17:34:22 25 4
gpt4 key购买 nike

我有这段代码可以将我的分数提交到游戏中心,但是每当我在游戏中心提交分数时,它都会说我的分数是 0。我不确定这是怎么发生的?我还导入了 GameKit 框架。

-(IBAction)submitScore{
if (highscore>0) {
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:@"MyLeaderBoardID"] autorelease];

scoreReporter.value = [[NSNumber numberWithInt:highscore] longLongValue];
NSLog(@"posted");
NSLog(@"%i",highscore);

[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"failed!!!");
NSLog(@"%i",highscore);
} else {
NSLog(@"Succeded");
}
}];
}

我还有这个登录代码:

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) {
if (error == nil) {
NSLog(@"authintication success");
} else {
NSLog(@"authintication failed");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Game Center Disabled"
message:@"For Game Center make sure you have an account and you have a proper device connection."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
}];

self.currentLeaderBoard = @"MyLeaderBoardID";

最佳答案

仅供引用,你的分数是多少?

您应该有两个不同的变量来读取旧乐谱和新乐谱。如果您的新分数大于旧分数,您希望将 if 语句设置为 true。将其设置为大于零将使其在每次用户得分大于 0 时不断变化。

关于ios - Xcode-提交分数到GameCenter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10269869/

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