Monday, October 29, 2012

Apple introduced the Game Kit API

As part of iPhone OS 3, Apple introduced the Game Kit API. Game Kit is a new framework that aims to solve two main problems facing application and game developers. The first problem is the ability to create ad hoc peer-to-peer networks among devices within close proximity to each other. To satisfy this need, Game Kit provides a sophisticated, yet simple-to-use mechanism for doing exactly this over the Bluetooth networking capability built into iPhone and the second-generation iPod Touch. The second problem is the ability to add in-game voice to applications.

This is a common requirement among applications that enable multi-user play, and including this capability is generally beyond the abilities or resources of most developers. To solve this, Game Kit provides an easy-to-use in-game voice capability that leverages Apple’s prior experience in adding voice to chat, and brings that power to the realm of developers. Developers don’t need to know about codec’s, or protocols; they just use the API, and everything is handled for them.

In this chapter, you’ll examine these two frameworks and see how you can leverage them in your games and applications. In particular, it should be pointed out that just because it’s called Game Kit doesn’t mean that the features in this API are only applicable to games. The peer-to-peer networking capability, in particular, could be leveraged by applications to exchange data amongst multiple users of a particular application when they are in close proximity.

Providing Peer-to-Peer Connectivity

The first feature of Game Kit that I’m going to discuss is its ability to provide an ad hoc peer-to-peer network to devices within close proximity to each other. This functionality is provided primarily by the GK Peer Picker Controller and GK Session classes. Before using the Game Kit API, you must first add the Game Kit framework to your project. Do this by right-clicking your target, choosing Get Info, and then choosing the General tab. Click the + button at the bottom of the window under Linked Libraries, and then choose the Game Kit framework. You must also include the Game Kit. h file in your source file.

Finding peers

The GK Peer Picker Controller class provides the mechanism by which you find other peers on your local Bluetooth ad hoc network. Using it, you can retrieve a list of all of the other devices in the vicinity that are currently available for networking with your application. It also allows the user to find peers over the Internet, but when you choose to use the Internet instead of Bluetooth, you need to dismiss the GK Peer Picker Controller and present your own user interface to complete the connection. GK Peer Picker Controller does not handle actually making peer connections over the Internet. To allocate and display a GK Peer Picker Controller, you simply need to initialize it, configure the allowed network types, and then set your delegate. Finally, to actually display it onscreen, you call the show method. Listing 21.1 shows a typical implementation of setting up and displaying a GK Peer Picker Controller.

BIO:

Brents Lyons is an IT professional from Exam key. Are you really looking for this 350-030 exam assistance? Move ahead to take the benefit of tk0-201 and pass your exam easily .


No comments:

Post a Comment