Introducing HelloGameKitiOS

/ 20 July 2017 / Eric Celeste

Alex and I have been trying to write a turn-based game for iOS for quite some time. Last year we set it aside because we were seeing too many bugs in Apple’s Game Center and Apple’s documentation of turn-based games was severely lacking.

A few weeks ago I noticed that Apple released an example app called HelloGameKit last October. Unfortunately, this is a watchOS example, and Apple provided no instructions for how to actually get the code to work properly (Game Center games need to be registered with Apple, and we could not figure out which components needed what registration and capabilities in order to actually run properly on the watch).

Still, the Swift code was very helpful. We have now transformed this example into one that targets iOS instead of watchOS and released it as HelloGameKitiOS. We even included a few hints about how to actually get the game to run on your device (note, this will require an Apple developer account).

The “game” is pretty rudimentary. Players alternate turns and during their turn they can poke the other players. A turn simply captures the player’s id and a timestamp. The pokes disappear with each turn. But the game is sufficient to demonstrate how to communicate with the Game Center servers, how to update players of progress during a turn, and how to notice and trap errors coming from Game Center.

Now we will turn our attention back to the game we were working on last year. I hope this skeleton will help us resolve the Game Center issues we were encountering. And I hope that sharing this example may help others struggling with the same issues find some clues.

So please, if you are trying to get a turn-based game working with Swift, iOS, and Apple’s Game Center, give HelloGameKitiOS a look. If you have ideas about how to improve this example, feel free to communicate with us via the BitBucket issue tracker.

Discussion