Game Development Reference
In-Depth Information
#pragma mark - Overridden Methods
-(void)didMoveToView:(SKView *)view {
/* Setup your scene here */
[self
addGameInfoLabelWithText:kConnectingDevicesText];
}
5. Declare an
enum
,
GameState
, and a property corresponding to it in the private
interface of
GameScene
. Also, set the initial state of game as
kGameStatePlayerToConnect
, as, to start a multiplayer game, players
need to be connected first to play. Add these lines just above the hash defines:
typedef enum {
kGameStatePlayerToConnect,
kGameStatePlayerAllotment,
kGameStatePlaying,
kGameStateComplete,
} GameState;
6. Add this property of
gameState
in the private interface of
GameScene
:
@property (nonatomic, assign) GameState gameState;
7. Assign
gameState
to
kGameStatePlayerToConnect
in
didMoveToView
of
GameScene
:
self.gameState = kGameStatePlayerToConnect;
8. Create a method called
instantiateMCSession
and add the
pragma
mark
as shown in the following code:
#pragma mark - Networking Related Methods
- (void)instantiateMCSession
{
if (self.gameSession == nil)
{
UIDevice *device = [UIDevice currentDevice];