Adobe AIR Native Extension Game Kit by Vitapoly. How accept invitation?

200 views Asked by At

I’m trying to make the real time game. When the player accepts invitation, realTimeMatchesController will dispatch an INVITE_ACCEPTED_EVENT event. But realTimeMatchesController.currentMatch is null. And MATCH_MAKER_FOUND_MATCH_EVENT events not dispatches. So the game is stuck at this point.

How to create a match, when an INVITE_ACCEPTED_EVENT is dispatched?

Here is the sample code

public function GameCenter()
 {
 if (!GameKit.isSupported)
 {
 return;
 }

_gamekit = GameKit.instance;

_gamekit.addEventListener(GameKit.LOCAL_PLAYER_AUTHENTICATED_EVENT, localPlayerAuthenticated);
 _gamekit.addEventListener(GameKit.LOCAL_PLAYER_NOT_AUTHENTICATED_EVENT, localPlayerNotAuthenticated);

_gamekit.authenticateLocalPlayer();

_gamekit.realTimeMatchesController.addEventListener(RealTimeMatchesController.INVITE_PLAYERS_EVENT, invitePlayersHandler);

_gamekit.realTimeMatchesController.addEventListener(RealTimeMatchesController.INVITE_ACCEPTED_EVENT, inviteAcceptedHandler);

_gamekit.realTimeMatchesController.init();

_gamekit.realTimeMatchesController.addEventListener(RealTimeMatchesController.MATCH_MAKER_CANCELLED_EVENT, matchMakerCancelled);

_gamekit.realTimeMatchesController.addEventListener(RealTimeMatchesController.MATCH_MAKER_FAILED_EVENT, matchMakerFailed);

_gamekit.realTimeMatchesController.addEventListener(RealTimeMatchesController.MATCH_MAKER_FOUND_MATCH_EVENT, matchMakerFoundMatch);

}

// inviter create the match
public function createMatch():void{
 _gamekit.realTimeMatchesController.startMatch(minPlayers, maxPlayers, playerGroup);
}

private function inviteAcceptedHandler(e:InviteAcceptedEvent):void
 {
 // how to start a match here?
 }

 private function matchMakerFoundMatch(e:MatchEvent):void
 {
 // save the match
  _currentMatch = e.realTimeMatch;
 _currentMatch.addEventListener(RealTimeMatch.RECEIVED_DATA_EVENT, dataReceivedHandler);
 if (_currentMatch.expectedPlayerCount == 0)
 {
  startGame();
 }
 }
0

There are 0 answers