我正在编写一个自定义排行榜,我只想知道玩家 ID,他/她在排行榜上的位置。
我找到了这个帖子:本地认证玩家在游戏中心排行榜中的排名
但我在实施它时遇到了麻烦。这是我所拥有的:
-(void) retrieveScoresForPlayers:(NSArray*)players
category:(NSString*)category
range:(NSRange)range
playerScope:(GKLeaderboardPlayerScope)playerScope
timeScope:(GKLeaderboardTimeScope)timeScope
{
if (isGameCenterAvailable == NO)
return;
GKLeaderboard* leaderboard = nil;
if ([players count] > 0)
{
//leaderboard = [[[GKLeaderboard alloc] initWithPlayerIDs:players] autorelease];
leaderboard = [[[GKLeaderboard alloc] initWithPlayerIDs:[NSArray arrayWithObject:[GKLocalPlayer localPlayer]]] autorelease];
}
else
{
leaderboard = [[[GKLeaderboard alloc] init] autorelease];
leaderboard.playerScope = playerScope;
}
if (leaderboard != nil)
{
leaderboard.timeScope = timeScope;
leaderboard.category = category;
leaderboard.range = range;
[leaderboard loadScoresWithCompletionHandler:^(NSArray* scores, NSError* error)
{
[self setLastError:error];
//[delegate onScoresReceived:scores];
if (_gkhDelegate != NULL) {
_gkhDelegate->onScoresReceived([self convertNSArrayOfGKScoresToCppVector:scores]);
}
}];
}
}
每当我打印排名时,无论实际数字如何,它始终为 1。我怀疑它正在返回查询中的排名。如何返回排行榜中的绝对位置?