Game Development Reference
In-Depth Information
TileMapLayer class to submit a dummy score to Game Center, under the Play-
time category:
-(void) onPlayerInfoReceived:(NSArray*)players
GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper];
[gkHelper submitScore:1234 category:@"Playtime"];
The submitScore method shown in Listing 14-9 is implemented in
GameKitHelper and calls the onScoresSubmitted message back to the deleg-
ate. Because there's no return parameter to pass on, it simply reports through the suc-
cess value if the score was transmitted without an error.
Listing 14-9 . Submitting a Score to a Leaderboard
-(void) submitScore:(int64_t)score category:(NSString*)category
if (isGameCenterAvailable == NO)
GKScore* gkScore = [[GKScore alloc] initWithCategory:category];
gkScore.value = score;
[gkScore reportScoreWithCompletionHandler:←
^(NSError* error)
[self setLastError:error];
BOOL success = (error == nil);
if ([delegate respondsToSelector:@selector(onScoresSubmitted:)])
[delegate onScoresSubmitted:success];
Search Nedrilad ::

Custom Search