Game Development Reference
In-Depth Information
self.gameSession.delegate = self;
self.gameState = kGameStatePlayerAllotment;
self.gameInfoLabel.text = kGameStartedText;
[self
sendNetworkPacketToPeerId:self.gamePeerID
forPacketCode:KNetworkPacketCodePlayerAllotment
withData:&gameUniqueIdForPlayerAllocation
ofLength:sizeof(int)
reliable:YES];
}
else if (state == MCSessionStateConnecting)
{
NSLog(@"state == MCSessionStateConnecting");
}
else if (state == MCSessionStateNotConnected)
{
NSLog(@"state == MCSessionStateNotConnected");
}
}
Here, in this method, set all properties that come from the method, as it is the re-
mote player information, and set the game state to kGameStatePlayerAl-
lotment locally. Then, we send the packet of the allotment of the player to
peerID , for which the connection has been established with a NetworkPack-
etCode and a data part, which would be received at the remote end as discussed
previously.
Finally, we are done with connecting two players for a multiplayer game and assigning
them a unique identity for further identification to build the game. This recipe acts as the
solution kit for this chapter.
Search WWH ::




Custom Search