iphone - Gamer Center 排行榜不显示分数,每个用户只能访问自己的分数

标签 iphone ios game-center leaderboard

我正在尝试使用 Game Center 在我的游戏中制作排行榜。我这样发布高分:

GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"grp.high_scores"] autorelease];
    myScoreValue.value = self.game.scoreMeter.score;

    NSLog(@"Attemping to submit score: %@", myScoreValue);

    [myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
        if(error != nil){
            NSLog(@"Score Submission Failed");
        } else {
            NSLog(@"Score Submitted");
            id appDelegate = [[UIApplication sharedApplication] delegate];
            [appDelegate displayLeaderBoard:nil];
        }

    }];

我按预期看到“分数已提交”,它会调出 Game Center 排行榜 View ,但它只是显示“无分数”

我知道其他人说过you need at least two accounts ,但我已经尝试了三个。

对于每个帐户,游戏会在 Game Center 应用程序中为他们显示,当我查询前十名时:

- (void) retrieveTopTenScores
{
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
    if (leaderboardRequest != nil)
    {
        leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
        leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
        leaderboardRequest.range = NSMakeRange(1,10);
        [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
            if (error != nil)
            {
                NSLog(@"Error grabbing top ten: %@", error);
            }
            if (scores != nil)
            {
                NSLog(@"Top ten scores: %@", scores);
            }
        }];
    }
}

每个用户只能看到自己的分数。

那么为什么排行榜是空的,为什么每个用户只能看到自己的分数?

最佳答案

沙盒有时会很乱,但让我问你这个。你的 self.game.scoreMeter.score 是一个整数吗?

如果是这样,请尝试这样做:

myScoreValue.value = [[NSNumber numberWithInt:self.game.scoreMeter.score] longLongValue];

用于设置 GKScore 对象的值。如果它有任何变化,请告诉我。

关于iphone - Gamer Center 排行榜不显示分数,每个用户只能访问自己的分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11681350/

相关文章:

php - 某些设备未收到 Apple 推送通知

ios - Xcode 6 从 UIViewController 访问 UIApplication

Swift 任务延续误用;函数多次尝试恢复其继续

iOS9 “This game is not recognized by game center.”

iphone - 任何好的免费网站模板或 wordpress 或 joomla 主题来演示我的手机应用程序?

iphone - 查找 iPhone 上 OpenGL 应用程序的瓶颈

ios - 通过参数将数据从 Swift 中的 iOS 发送到 Rails 应用程序

ios - 如何在 Objective-C 的框架中设置常量文件

ios - 游戏中心和安全

iphone - 在具有不同数据库状态的模拟器上自动测试 Coredata iOS 应用程序