【问题标题】:iOS testing game center leaderboard with different test users不同测试用户的iOS测试游戏中心排行榜
【发布时间】:2014-07-24 23:12:03
【问题描述】:

我已经通过 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];
}

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

【问题讨论】:

    标签: ios sprite-kit gamekit leaderboard


    【解决方案1】:

    我回答了类似here 的问题,基本上是游戏中心沙盒帐户的问题。

    【讨论】:

      猜你喜欢
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-20
      相关资源
      最近更新 更多