Game Development Reference
In-Depth Information
[self addGameInfoLabelWithText:kGameWonText];
[self restartGameAfterSomeTime];
[self
sendNetworkPacketToPeerId:self.gamePeerID
forPacketCode:KNetworkPacketCodePlayerLost
withData:nil
ofLength:0
reliable:YES];
}
else if(self.localTankSprite ==
self.redTankSprite &&
CGRectIntersectsRect(self.localTankSprite.frame,
redFinishLineFrame))
{
self.gameState = kGameStateComplete;
[self addGameInfoLabelWithText:kGameWonText];
[self restartGameAfterSomeTime];
[self
sendNetworkPacketToPeerId:self.gamePeerID
forPacketCode:KNetworkPacketCodePlayerLost
withData:nil
ofLength:0
reliable:YES];
}
}
3. When the preceding game lost packet is sent to the other player, a delegate meth-
od of MCSession named didReceiveData is called, with a Net-
workPacketCode in the header of the packet named KNetworkPack-
etCodePlayerLost . When this packet is received, the game state is changed
to kGameStateComplete and the game information label is shown as You
Lose to inform the other user of losing the game. Also, we call a method re-
Search WWH ::




Custom Search