首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有不同测试用户的iOS测试游戏中心排行榜

具有不同测试用户的iOS测试游戏中心排行榜
EN

Stack Overflow用户
提问于 2014-07-25 07:12:03
回答 1查看 397关注 0票数 0

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

代码语言:javascript
复制
#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];
}

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

EN

回答 1

Stack Overflow用户

发布于 2014-07-25 14:48:44

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24945486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档