我想localPlayer
在我的应用中显示好友排行榜。我知道我只能从游戏中心获得朋友的分数,但我如何获得他们的显示名称?我知道我可以使用loadPlayersForIdentifiers
,但我必须打两个电话吗?一个得到他们所有朋友的名字,一个得到排行榜,他们匹配他们?这似乎有些低效?
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
{
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardRequest.category = @"HighScore";
leaderboardRequest.range = NSMakeRange(1,100);
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil)
{
// Handle the error.
}
if (scores != nil)
{
GKScore* myScore = leaderboardRequest.localPlayerScore;
NSLog(@"Me: %@: %d",myScore.playerID, (int)myScore.value);
// Process the score information - here I would filter
for (GKScore* score in scores)
{
NSLog(@"%@: %d",score.playerID, (int)score.value);
}
}
}];
}