Game Development Reference
In-Depth Information
Feel free to add more wrapper methods for retrieving scores as you see fit, depending
on your game's needs. Because there are a variety of ways to retrieve leaderboard
scores and several filters to reduce the number of scores retrieved, it makes sense to
use wrapper methods to reduce the potential for human error. Listing 14-10 shows the
retrieveScoresForPlayers method in full.
Listing 14-10 . Retrieving a List of Scores from a Leaderboard
-(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];
}
else
{
leaderboard = [[GKLeaderboard alloc] init];
leaderboard.playerScope = playerScope;
}
if (leaderboard != nil)
{
leaderboard.timeScope = timeScope;
leaderboard.category = category;
leaderboard.range = range;
[leaderboard loadScoresWithCompletionHandler:←
^(NSArray* scores, NSError* error)
{
 
 
Search Nedrilad ::




Custom Search