iOS测试游戏中心排行榜不同测试用户

标签 ios sprite-kit gamekit leaderboard

我已经通过 itunes-connect 对 3~4 个测试用户进行了测试,以查看我的排行榜实现是否正常工作。因此,我使用在一台设备上创建的 2-3 个不同帐户玩我的游戏。但是每次登录账号上报分数,在排行榜上只能看到自己的分数,而且是唯一的参与者。这是预期的还是我报告的所有帐户都应该出现在排行榜上?

#pragma mark leaderboard 
- (void)authenticateLocalPlayer {
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
        if (viewController != nil) {
            [self presentViewController:viewController animated:YES completion:nil];
        }
        else{
            if ([GKLocalPlayer localPlayer].authenticated) {
                _gameCenterEnabled = YES;

                // Get the default leaderboard identifier.
                [[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {

                    if (error != nil) {
                        NSLog(@"%@", [error localizedDescription]);
                    }
                    else{
                        _leaderboardIdentifier = leaderboardIdentifier;
                    }
                }];
            }

            else{
                _gameCenterEnabled = NO;
            }
        }
    };
}


- (void)reportScore:(NSNotification *) notification {
    NSDictionary *userInfo = notification.userInfo;
    NSNumber *score = [userInfo objectForKey:@"highestScore"];
    GKScore *gkscore = [[GKScore alloc]initWithLeaderboardIdentifier:_leaderboardIdentifier];
    gkscore.value = [score integerValue];
    [GKScore reportScores:@[gkscore] withCompletionHandler:^(NSError *error) {
        if (error != nil) {
            NSLog(@"%@", [error localizedDescription]);
        }
    }];

}

- (void)showLeaderboard{
    GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc] init];
    gcViewController.gameCenterDelegate = self;

    gcViewController.viewState = GKGameCenterViewControllerStateLeaderboards;
    gcViewController.leaderboardIdentifier = _leaderboardIdentifier;

    [self presentViewController:gcViewController animated:YES completion:nil];
}

- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
{
    [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
}

这是我在我的项目中实现的排行榜。

最佳答案

我回答了类似的问题here ,这基本上是 Game Center 中沙盒帐户的问题。

关于iOS测试游戏中心排行榜不同测试用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24945486/

相关文章:

iOS6 TurnBasedMatch 问题

ios - TableView 标题中的 UISearchController 搜索栏留下状态栏大小的间隙

ios - 每天调用一次 Firebase 数据库

ios - 无法理解 Firebase 数据库规则

ios - 来自 SKPhysicsBody applyImpulse 的奇怪行为

game-center - GameKit GKMatchMaker inviteHandler 在 iOS7 中弃用,替代者是什么?

ios - iOS:如果没有GPS,是否可以检测用户是否在驾驶车辆?

ios - 改变火的方向

ios - 如何在第一次点击后停止重新生成墙?

ios - 如何在 iOS 7 中通过游戏中心应用程序邀请玩家?