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

Assigning roles to players


In this recipe, we will take our game template to the next step by assigning the roles to our players. This means we will be logically dividing the users and assigning roles to them. This will provide an individual identity to the players.

Getting ready

Before starting with assigning or as we can also call it, an allotment of players identity (which is first player and second player), we should be familiar with the Multipeer Connectivity framework. We must also have a basic knowledge of network packet sending and receiving. In this section we will be assigning the first and second player identities to the players once they are connected using the MCBrowserViewController having just described it in the preceding recipe by pressing the Done button.

How to do it

To accomplish the assignment of players, following are the steps to be followed:

  1. For a set up purpose for this add some enums, hash define constants and properties as shown below:

    • Declare an enum called NetworkPacketCode...