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:
For a set up purpose for this add some enums, hash define constants and properties as shown below:
Declare an
enum
calledNetworkPacketCode...