0

我想通过使用 Game Center 来实现排名。

所以,我是这样实现的。

-(void)authenticateLocalPlayer
{

    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];


    localPlayer.authenticateHandler = ^(UIViewController *vc,NSError *err){
        [self setLastError:err];
        if ([CCDirector sharedDirector].isPaused){
            [[CCDirector sharedDirector] resume];
        }
        if (localPlayer.authenticated){
            _gameCenterFeaturesEnabled = YES;

            // get localplayer's score.
            GKLeaderboard *board = [[GKLeaderboard alloc] init];

            // make a query

            board.timeScope = GKLeaderboardTimeScopeAllTime;
            // I want to get all player's score.
            board.playerScope = GKLeaderboardTimeScopeToday;


            // set my game category.
            board.category = @"com.nobinobiru.shooting";

            // I want to show top 3 score data.
            board.range = NSMakeRange(1, 3);

            [board loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
                NSString *s = [NSString stringWithFormat:@"%lld",board.localPlayerScore.value];
                [ud setObject:[NSString stringWithFormat:@"%@",s] forKey:@"bestScore"];
                if (scores){
                    // I want to 3 items but it returned only 1 item.
                    NSLog(@"score is %@",scores);
                }


            }];

        }else if (vc){
            [[CCDirector sharedDirector] pause];
            [self presentViewController:vc];
        }

    };
}

然后,我创建了 3 个沙盒的用户帐户,并对其进行了测试。但它总是只显示当前用户的最好成绩。

我想显示 3 个沙盒的数据。

我不知道为什么会这样。我的代码在非沙箱环境中运行良好?你有什么主意吗?

提前致谢。

4

1 回答 1

0

全部。6小时后完美运行...

我认为发生这种情况的原因是我创建的游戏中心帐户没有立即反映。

于 2013-02-24T08:16:05.303 回答