O'Reilly logo

Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch by Kyle Richter

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

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 ...

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