Setting Up Our Engine for Multiplayer
The very first thing that we need to do is let our game engine know whether the state should be set to multiplayer or single player. There are complex ways and simple ways of doing this. Depending on your needs, you will most likely be able to get away with a simple state variable.
A state variable is the approach that we will use for our example, since our game is extremely straightforward. In UFOGameViewController.h, we create a new ivar to represent a BOOL, which will be set to inform the class whether we are in single-player or multiplayer mode. Add the following two bold lines into our already existing header file, and don't forget to synthesize gameIsMultiplayer in the implementation.
@interface UFOGameViewController ...
Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.