Game Development Reference
In-Depth Information
-(void) match:(GKMatch*)match player:(NSString*)playerID←
didChangeState:(GKPlayerConnectionState)state
{
switch (state)
{
case GKPlayerStateConnected:
if ([delegate respondsToSelector:@selector(onPlayerConnected:)])
{
[delegate onPlayerConnected:playerID];
}
break;
case GKPlayerStateDisconnected:
if ([delegate respondsToSelector:@selector(onPlayerDisconnected:)])
{
[delegate onPlayerDisconnected:playerID];
}
break;
}
if (matchStarted == NO && match.expectedPlayerCount == 0)
{
matchStarted = YES;
if ([delegate respondsToSelector:@selector(onStartMatch)])
{
[delegate onStartMatch];
}
}
}
If at any time during your game a player drops out and the expectedPlayerCount
property becomes greater than 0 , you can call addPlayersToMatch to fill up the
now empty space with a new player, as in Listing 14-23 (assuming that your game sup-
ports players joining a match in progress). Because there's no guarantee that a player
will actually be found, you shouldn't interrupt the game while GKMatchmaker is
looking for a new player.
Listing 14-23 . Adding Players to an Existing Match
 
 
Search Nedrilad ::




Custom Search