Skip to content

Instantly share code, notes, and snippets.

@FrancescoMaisto
Last active December 27, 2015 23:49
Show Gist options
  • Save FrancescoMaisto/7408946 to your computer and use it in GitHub Desktop.
Save FrancescoMaisto/7408946 to your computer and use it in GitHub Desktop.
Code sample to use the GameCenter ANE
import com.adobe.ane.gameCenter.GameCenterAuthenticationEvent;
import com.adobe.ane.gameCenter.GameCenterController;
private var gcController:GameCenterController;
private function initializeGameCenter():void
{
if (GameCenterController.isSupported)
{
trace ("gamecenter is supported");
gcController = new GameCenterController();
if (!gcController.authenticated)
{
trace ("Authentication initiated");
gcController.addEventListener(GameCenterAuthenticationEvent.PLAYER_AUTHENTICATED, authTrue);
gcController.addEventListener(GameCenterAuthenticationEvent.PLAYER_NOT_AUTHENTICATED, onPlayerNotAuthenticated);
gcController.authenticate();
}
}
else
{
trace ("gamecenter is NOT supported");
}
}
// --------------------------------------------------------------------------------------------------------------
private function authTrue(e:GameCenterAuthenticationEvent):void
{
trace ("PLAYER AUTHENTICATED!");
if(gcController.localPlayer!=null)
trace ("Localplayer:" + gcController.localPlayer.alias+" playerID:"+gcController.localPlayer.id + " playerIsFriend:"+gcController.localPlayer.isFriend);
else
trace("null");
}
// --------------------------------------------------------------------------------------------------------------
private function onPlayerNotAuthenticated(e:GameCenterAuthenticationEvent):void
{
trace ("PLAYER NOT AUTHENTICATED");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment