Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

24. GameKit > Matchmaking: Multiplayer GameKit Matches

Matchmaking: Multiplayer GameKit Matches

GameKit enables your users to solicit matches with other players, whether those players are friends or anonymous other persons. The matchmaker view controller handles both specific invitations and general random game matches. To get started with a matchmaking session, create a new match request. Specify how many players are required for gameplay and how many players can be handled total. For Game Center gameplay, you can create matches for two to four players. Hosted matches on your own servers can allow up to 16 players at once. This chapter does not cover hosted matches outside of Game Center. The following snippet creates a request for a basic two-player game:

- (void) startMatch
{
    // Clean up any previous game
    sendingView.text = @"";
    receivingView.text = @"";

    // This is not a hosted match, which allows up to 16 players
    GKMatchRequest *request = [[GKMatchRequest alloc] init];
    request.minPlayers = 2; // Between 2 and 4
    request.maxPlayers = 2; // Between 2 and 4

    GKMatchmakerViewController *mmvc =
        [[GKMatchmakerViewController alloc]
            initWithMatchRequest:request];
    mmvc.matchmakerDelegate = self;
    mmvc.hosted = NO;

    [self presentModalViewController:mmvc animated:YES];
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial