Making the First Move

The first thing we need to do in a new match-based game, before we make a move, is determine who the player is representing. In our example game, there are two sides: X and O. We are going to set the first person to always be X, and the second to always be O. This means that X will always make the first move. With this setup, it becomes easy to determine who the player currently is representing using the following code snippet.

if (match.currentParticipant == [match.participants objectAtIndex:0]) {     myPlayerCharacter = @"X";     identifyTeamLabel.text = @"It is X's Turn"; } else {     myPlayerCharacter = @"O";     identifyTeamLabel.text = @"It is O's Turn"; }

After we have determined who the users are, then we can allow ...

Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.