Book Image

iOS Game Programming Cookbook

Book Image

iOS Game Programming Cookbook

Overview of this book

Table of Contents (19 chapters)
iOS Game Programming Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 and establish connection between players (that is, devices). MCBrowserViewController is fully equipped and designed for connecting multiple players for a session provided in the Multipeer Connectivity framework. These are the steps...