0

I have been developing a game for Game Center.

Description of game :-

One player is initiator of game because game has 5 tiled-map (only one tile-map is selected randomly by either player(initiator)) . Initiator will send selected tile-map to second player, Now this tile-map will draw on second player side.(at this point both player have same tile-map)

This is work fine when I start game by sending invitation to player.

but when I start game by "automatch" , I am not able to find that who will be the initiator(who will send randomly selected tile-map).

I have made one player initiator by this code:

isThisInvited_Player = YES;  
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_INVITATION_ACCEPTED object:nil];


- (void)authenticationChanged {    

    if ([GKLocalPlayer localPlayer].isAuthenticated && !userAuthenticated) {
       userAuthenticated = TRUE;  

    [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {

        isThisInvited_Player = YES;
        self.pendingInvite = acceptedInvite;
        self.pendingPlayersToInvite = playersToInvite;
        [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_INVITATION_ACCEPTED object:nil];

    };

} else if (![GKLocalPlayer localPlayer].isAuthenticated && userAuthenticated) {
   userAuthenticated = FALSE;
}

}

if data sync is not possible in "automatch", then please tell me , how can I disable the automatch(Play) button in game-center-view-controller.

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216

1 Answers1

1

You could pick who the initiator is by sorting the two players by their playerIDs and then always have the first one in the sorted array be the initiator.

machoota
  • 289
  • 2
  • 5