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];
}
}];
「Score Submitted」が期待どおりに表示され、Game Center リーダーボード ビューが表示されますが、「No Scores」としか表示されません。
少なくとも 2 つのアカウントが必要だと他の人が言っていることは知っていますが、私はすでに 3 つ試しました。
アカウントごとに、Game Center アプリにゲームが表示され、上位 10 のスコアを照会すると、次のようになります。
- (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);
}
}];
}
}
各ユーザーには自分のスコアのみが表示されます。
では、リーダーボードが空で、各ユーザーが自分のスコアしか表示していないのはなぜでしょうか?