Chapter 10

Building a Networked Game with GameKit

What You Will Learn In This Chapter:

  • Creating a peer-to-peer network with GameKit
  • Implementing the NSCoding protocol to enable serialization and deserialization of your objects
  • Converting your classes to serialized data by using archivers
  • Building a peer-to-peer networked game

Introducing GameKit

The final iOS framework that you will look at in this book is GameKit. As you may expect, you can use the GameKit framework to add some interesting functionality to your games. GameKit provides three somewhat distinct sets of functionality:

  • Game Center: GameKit helps you to integrate Game Center features into your game. The Game Center application is part of the core iOS installation and is available on every phone running iOS 4 or greater. GameKit provides classes to let you authenticate a player with their Game Center account, add Achievements to your games, Auto-match players that want to play your game, and track and display game scores with Leaderboards.
  • Peer-to-peer connectivity: GameKit provides APIs to allow you to easily set up peer-to-peer networked games using either Bluetooth or a local wireless network.
  • In-Game Voice: GameKit contains classes that enable you to provide in-game voice chat to your game's players.

This chapter will focus on the peer-to-peer connectivity portion of the GameKit framework. In this chapter, you will build a tic-tac-toe game and then enable head-to-head play by using the peer-to-peer networking ...

Get Beginning iOS Game Development now with the O’Reilly learning platform.

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