Last active
December 27, 2015 23:49
-
-
Save FrancescoMaisto/7408946 to your computer and use it in GitHub Desktop.
Code sample to use the GameCenter ANE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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