Game Development Reference
In-Depth Information
[self presentViewController:viewController
animated:YES completion:nil];
}
In this method, MCBrowserViewController is presented on
GameViewController with its delegate set and restricted the peers to 2 .
6. Add two public methods to GameScene , to be called the cancel and done actions
of MCBrowserViewController .
◦ In GameScene.h , declare the public methods, as follows:
#pragma mark - Public Methods
- (void)startGame;
- (void)discardSession;
◦ In GameScene.m , define the public methods, like this:
- (void)startGame
{
self.gameInfoLabel.text =
kConnectedDevicesText;
}
- (void)discardSession
{
self.gameState = kGameStatePlayerToConnect;
self.gameSession = nil;
self.gamePeerID = nil;
self.serviceType = nil;
self.advertiser = nil;
}
7. Now we will add two public methods in the GameScene file. These methods
will be invoked on the cancel and done actions of MCBrowserViewControl-
lerDelegate respectively:
#pragma mark - MCBrowserViewControllerDelegate Methods
-
Search WWH ::




Custom Search