Packagecom.milkmangames.nativeextensions.ios
Classpublic class GameCenter
InheritanceGameCenter Inheritance flash.events.EventDispatcher

GameCenter



Public Properties
 PropertyDefined By
  gameCenter : GameCenter
[static] [read-only] The current instance of the GameCenter singelton.
GameCenter
Public Methods
 MethodDefined By
  
GameCenter(logCallback:Function = null)
Do not call this directly; use GameCenter.create() to initialize or GameCenter.gameCenter to get current instance.
GameCenter
  
Sends request to authenticate (log in) the user on GameCenter.
GameCenter
  
[static] Initializes the GameCenter Extension.
GameCenter
  
dispose():void
Dispose of Context
GameCenter
  
Gets the Alias (human-readable name) of the current logged in player.
GameCenter
  
getPlayerID():String
Get the unique identifier of the current logged in player.
GameCenter
  
Checks if GameCenter is available on the running device.
GameCenter
  
Check if the current logged in player is 'underage' in the GameCenter database.
GameCenter
  
isSupported():Boolean
[static] Checks if the current platform supports GameCenter.
GameCenter
  
Check if the user is currently logged in and authenticated with GameCenter.
GameCenter
  
reportAchievement(achievementId:String, completion:Number):void
Report achievement progress to the GameCenter server.
GameCenter
  
reportScoreForCategory(score:int, category:String):void
Report a score to the GameCenter server.
GameCenter
  
Sends a request to reset the user's achievements in this game.
GameCenter
  
Shows the iOS Achievements view for the user on GameCenter.
GameCenter
  
showLeaderboardForCategory(category:String):void
Shows the iOS Leaderboard view for the user on GameCenter.
GameCenter
Events
 Event Summary Defined By
  Dispatched when an achievement submission failed after a call to gameCenter.reportAchievement()GameCenter
  Dispatched when an achievement submission succeeded after a call to gameCenter.reportAchievement()GameCenter
  Dispatched when an achievement reset failed after a call to gameCenter.resetAchievements()GameCenter
  Dispatched when an achievement reset succeeded after a call to gameCenter.resetAchievements()GameCenter
  Dispatched when the default achievement view has been dismissed by the user.GameCenter
  Dispatched when the default leaderboard view has been displayed, after a call to gameCenter.showAchievements()GameCenter
  Dispatched when authentication of the local user has failed after a call to gameCenter.authenticateLocalUser()GameCenter
  Dispatched when the user has been successfully authorized after a call to gameCenter.authenticateLocalUser()GameCenter
  Dispatched when the default leaderboard view has been dismissed by the user.GameCenter
  Dispatched when the default leaderboard view has been displayed, after a call to gameCenter.showLeaderboardForCategory()GameCenter
  Dispatched when a score submission failed after a call to gameCenter.reportScoreForCategory()GameCenter
  Dispatched when a score submission succeeded after a call to gameCenter.reportScoreForCategory()GameCenter
Public Constants
 ConstantDefined By
  VERSION : String = 1.0.0
[static] Current API Version
GameCenter
Property Detail
gameCenterproperty
gameCenter:GameCenter  [read-only]

The current instance of the GameCenter singelton. You must call GameCenter.create() before this property is available.


Implementation
    public static function get gameCenter():GameCenter
Constructor Detail
GameCenter()Constructor
public function GameCenter(logCallback:Function = null)

Do not call this directly; use GameCenter.create() to initialize or GameCenter.gameCenter to get current instance.

Parameters
logCallback:Function (default = null)
Method Detail
authenticateLocalUser()method
public function authenticateLocalUser():void

Sends request to authenticate (log in) the user on GameCenter. On completion, either GameCenterEvent.AUTH_SUCCEEDED or GameCenterErrorEvent.AUTH_FAILED will be dispatched.


Throws
Error — if the current device does not support GameCenter.

See also

create()method 
public static function create():GameCenter

Initializes the GameCenter Extension. You should check GameCenter.isSupported first to ensure the platform is iOS. GameCenter is a Singleton and you may have only one instance. After creation, you may access the instance through the static property GameCenter.gameCenter .

Returns
GameCenter — initialized instance of GameCenter extension interface.

Throws
Error — if GameCenter has already been initialized.
dispose()method 
public function dispose():void

Dispose of Context

getPlayerAlias()method 
public function getPlayerAlias():String

Gets the Alias (human-readable name) of the current logged in player.

Returns
String — the alias of the current logged in player.
getPlayerID()method 
public function getPlayerID():String

Get the unique identifier of the current logged in player.

Returns
String — the GameCenter player ID of the current logged in player.
isGameCenterAvailable()method 
public function isGameCenterAvailable():Boolean

Checks if GameCenter is available on the running device. GameCenter requires at least iOS 4.1; your app will run on iOS 4.0, but will not be able to use GameCenter features.

Returns
Boolean — true if the current device supports GameCenter (iOS 4.1+)
isPlayerUnderage()method 
public function isPlayerUnderage():Boolean

Check if the current logged in player is 'underage' in the GameCenter database. Apple may restrict some features for underage players.

Returns
Boolean — true if the currently authenticated player is underage.
isSupported()method 
public static function isSupported():Boolean

Checks if the current platform supports GameCenter. Note that this only determines whether the app is running under iOS (as opposed to Android, Windows, etc.), and will NOT tell you whether the particular device's iOS has GameCenter installed. Use this call before initializing GameCenter in order to confirm that you are on iOS. (So that you can avoid initializing GameCenter on an unsupported platform when building a multi-platform app.) After initialization, you can check if the particular iOS device has GameCenter installed with the call GameCenter.gameCenter.isGameCenterAvailable().

Returns
Boolean — true if GameCenter is supported; false otherwise.

See also

isGameCenterAvailable
isUserAuthenticated()method 
public function isUserAuthenticated():Boolean

Check if the user is currently logged in and authenticated with GameCenter.

Returns
Boolean — true if the user is authenticated with GameCenter.

Throws
Error — if the current device does not support GameCenter.
reportAchievement()method 
public function reportAchievement(achievementId:String, completion:Number):void

Report achievement progress to the GameCenter server. Either GameCenterEvent.ACHIEVEMENT_REPORT_SUCCEEDED or GameCenterErrorEvent.ACHIEVEMENT_REPORT_FAILED will be dispatched. Note that iOS will not automatically display a banner when an achievement is earned; you should listen for GameCenterEvent.ACHIEVEMENT_REPORT_SUCCEEDED show a banner there if you wish. It is best practice to store the state of the user's achievements in the case of a failed report, so you may try again later to report the progress. It is best practice be sure the user is logged in (via isUserAuthenticated()) prior to reporting a score.

Parameters

achievementId:String — the id of the achievement you are reporting; this is set in iTunes Connect when you define the achievements. Case-sensitive.
 
completion:Number — a value from 0.0-100.0, representing the percentage to which this achievement has been completed.


Throws
Error — if the current device does not support GameCenter.
 
Error — if completion argument is not in the range of 0 to 100.

See also

reportScoreForCategory()method 
public function reportScoreForCategory(score:int, category:String):void

Report a score to the GameCenter server. On completion, either GameCenterEvent.SCORE_REPORT_SUCCEEDED or GameCenterErrorEvent.SCORE_REPORT_FAILED will be dispatched. It is best practice be sure the user is logged in (via isUserAuthenticated()) prior to reporting a score.

Parameters

score:int — the score you would like to report for the current user.
 
category:String — the id of the leaderboard for which you wish to report score; this is set in iTunes Connect when you define the leaderboard. Case-sensitive.


Throws
Error — if the current device does not support GameCenter.

See also

resetAchievements()method 
public function resetAchievements():void

Sends a request to reset the user's achievements in this game. Once complete, either GameCenterEvent.ACHIEVEMENT_RESET_SUCCEEDED or GameCenterErrorEvent.ACHIEVEMENT_RESET_FAILED will be dispatched. Note that iOS will not ask the user to confirm they want to reset their progress; it is up to you to dislay a confirmation modal if you wish.


Throws
Error — if the current device does not support GameCenter.

See also

showAchievements()method 
public function showAchievements():void

Shows the iOS Achievements view for the user on GameCenter. Once the view is displayed, GameCenterEvent.ACHIEVEMENT_VIEW_OPENED will be dispatched; on dismissal, GameCenterEvent.ACHIEVEMENT_VIEW_CLOSED will be dispatched. You may use these events to pause and resume your own game UI interactions as appropriate.


Throws
Error — if the current device does not support GameCenter.

See also

showLeaderboardForCategory()method 
public function showLeaderboardForCategory(category:String):void

Shows the iOS Leaderboard view for the user on GameCenter. Once the view is displayed, GameCenterEvent.LEADERBOARD_VIEW_OPENED will be dispatched; on dismissal, GameCenterEvent.LEADERBOARD_VIEW_CLOSED will be dispatched. You may use these events to pause and resume your own game UI interactions as appropriate.

Parameters

category:String — the category ID of the leaderboard you wish to display; this is set in iTunes Connect when you define the leaderboard. Case-sensitive.


Throws
Error — if the current device does not support GameCenter.

See also

Event Detail
ACHIEVEMENT_REPORT_FAILED Event
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterErrorEvent

Dispatched when an achievement submission failed after a call to gameCenter.reportAchievement()

ACHIEVEMENT_REPORT_SUCCEEDED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when an achievement submission succeeded after a call to gameCenter.reportAchievement()

ACHIEVEMENT_RESET_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterErrorEvent

Dispatched when an achievement reset failed after a call to gameCenter.resetAchievements()

ACHIEVEMENT_RESET_SUCCEEDED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterErrorEvent

Dispatched when an achievement reset succeeded after a call to gameCenter.resetAchievements()

ACHIEVEMENTS_VIEW_CLOSED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when the default achievement view has been dismissed by the user.

ACHIEVEMENTS_VIEW_OPENED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when the default leaderboard view has been displayed, after a call to gameCenter.showAchievements()

AUTH_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterErrorEvent

Dispatched when authentication of the local user has failed after a call to gameCenter.authenticateLocalUser()

AUTH_SUCCEEDED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.GameCenterEvent

Dispatched when the user has been successfully authorized after a call to gameCenter.authenticateLocalUser()

LEADERBOARD_VIEW_CLOSED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when the default leaderboard view has been dismissed by the user.

LEADERBOARD_VIEW_OPENED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when the default leaderboard view has been displayed, after a call to gameCenter.showLeaderboardForCategory()

SCORE_REPORT_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterErrorEvent

Dispatched when a score submission failed after a call to gameCenter.reportScoreForCategory()

SCORE_REPORT_SUCCEEDED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.GameCenterEvent

Dispatched when a score submission succeeded after a call to gameCenter.reportScoreForCategory()

Constant Detail
VERSIONConstant
public static const VERSION:String = 1.0.0

Current API Version