We now have a complete two-player game on the same iPad. Now we will turn our attention to using GameKit to create a local Bluetooth game between two iPads. A word of caution to begin this discussion: this does not work correctly on the simulator, so you must have two iPads (any generation will do) in order to test this code.
To get the game prepared for using GameKit, we need to make sure the GameKit.framework
is included in our project. You can check this by selecting your target project, and selecting the "Build Phases" heading. Then, expand the Link Binary With Libraries tab, and see if it is listed. If it is not, click on the + button at the bottom of the section, and select GameKit.framework
.
In Xcode, it looks like the following screenshot:
We also need to make a couple of additions to the CLPlayfieldLayer.h
file to include the GameKit.
Filename:
CLPlayfieldLayer.h
(partial)
#import <GameKit/GameKit.h> @interface CLPlayfieldLayer : CCLayer <GKPeerPickerControllerDelegate...