Game Development Reference
In-Depth Information
[self setLastError:error];
if ([delegate respondsToSelector:@selector(onPlayerInfoReceived:)])
[delegate onPlayerInfoReceived:players];
Again, a block object is used to handle the returned results from the server. And as al-
ways, the lastError property is updated before calling the delegate's onPlayer-
InfoReceived method. The players array should now contain a list of GKPlay-
er class instances, which the delegate then simply prints to the Debugger Console win-
dow in the absence of a proper friend list user interface:
-(void) onPlayerInfoReceived:(NSArray*)players
for (GKPlayer* gkPlayer in players)
CCLOG(@"PlayerID: %@, Alias: %@", gkPlayer.playerID, gkPlayer.alias); }
The GKPlayer class has only three properties: the player identifier, an alias, and the
isFriend flag, which is true for all the players in this particular case. The alias is
simply the player's nickname.
If you created a new sandbox account, you won't have any friends, so it's normal for
the list to be empty. You can fix that by signing out of Game Center with the Game
Center app, creating another account by running your app again, and finally sending a
friend request to your previous sandbox account.
In the IsoTilemap04 project, I added functionality for posting and retrieving leader-
board scores. I hooked into the onPlayerInfoReceived method in the
Search Nedrilad ::

Custom Search