O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setup for a multiplayer game

In this recipe, we will write the code for setting up our multiplayer game. All the configurations and session managers will be the part of this section. We will dig into the various concepts of creating and maintaining sessions.

Getting ready

Before starting this recipe, MCSession, MCPeerId, advertiser and service type terms of Multipeer Connectivity framework should be known to us. In this recipe we will be establishing the connection between players, thereby, they can communicate in future, making the players play a game, which we will be doing in the next chapter.

How to do it

Now, on tapping the screen, a MCSession with a service type has been instantiated; we can use this session and service type to present a MCBrowserViewController ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required