Packagecom.myflashlab.air.extensions.gameCenter
Classpublic class LocalPlayer
InheritanceLocalPlayer Inheritance Player Inheritance Object

An object representing the authenticated Game Center player on a device.

At any given time, only one player may be authenticated on the device; this player must log out before another player can log in. Your game must authenticate the local player before using any Game Center features. Authenticating the player ensures that the player has created an account and is connected to Game Center. To authenticate the local player, call GameCenter.localPlayer.authenticate.

You can see whether the local player is authenticated by reading the GameCenter.localPlayer.isAuthenticated property. If authenticated is true, then the local player’s other properties are valid, and you can call other Game Center methods.



Public Properties
 PropertyDefined By
 Inheritedalias : String
[read-only] A string chosen by the player to identify themselves to other players.
Player
 InheriteddisplayName : String
[read-only] A string to display for the player.
Player
 InheritedguestIdentifier : String
[read-only] A developer created string used to identify a guest player.
Player
  isAuthenticated : Boolean
[read-only] A Boolean value that indicates whether a local player is currently signed in to Game Center.
LocalPlayer
  isUnderage : Boolean
[read-only] A Boolean value that declares whether the local player is underage.
LocalPlayer
 InheritedplayerID : String
[read-only] A unique identifier associated with a player.
Player
Protected Properties
 PropertyDefined By
 Inherited_alias : String
Player
 Inherited_context : ExtensionContext
Player
 Inherited_displayName : String
Player
 Inherited_guestIdentifier : String
Player
 Inherited_id : String
Player
Public Methods
 MethodDefined By
  
authenticate($callback:Function):void
Your game should authenticate the player as early as possible after launching, ideally as soon as you can present a user interface to the player.
LocalPlayer
 Inherited
createGuestPlayer($guestId:String):Player
[static] Creates a new guest player with the designated identifier.
Player
  
deleteSavedGame($name:String, $callback:Function):void
Deletes a specific saved game file.
LocalPlayer
  
fetchSavedGames($callback:Function):void
Retrieves all available saved games.
LocalPlayer
 Inherited
load($playerIDs:Vector.<String>, $callback:Function):void
[static] Loads information from Game Center about a list of players.
Player
  
loadDefaultLeaderboardId($callback:Function):void
Loads the category identifier for the local player’s default leaderboard.
LocalPlayer
 Inherited
loadPhoto($size:int, $callback:Function):void
Loads a photo of this player from Game Center.
Player
  
loadRecentPlayers($callback:Function):void
Returns an array of players the local player recently played with or any players that are on the local player's legacy friends list.
LocalPlayer
  
observeAuthentication($callback:Function):void
Watch user authentication status.
LocalPlayer
  
resolveConflicts($savedGames:Array, $gameData:String, $callback:Function):void
Resolves any conflicting saved games.
LocalPlayer
  
saveGame($name:String, $gameData:String, $callback:Function):void
Saves game data under the specified name.
LocalPlayer
  
setDefaultLeaderboardId($leaderboardId:String, $callback:Function):void
Sets the default leaderboard for the current game.
LocalPlayer
Protected Methods
 MethodDefined By
  
onStatus(e:StatusEvent):void
[override]
LocalPlayer
Property Detail
isAuthenticatedproperty
isAuthenticated:Boolean  [read-only]

A Boolean value that indicates whether a local player is currently signed in to Game Center.


Implementation
    public function get isAuthenticated():Boolean
isUnderageproperty 
isUnderage:Boolean  [read-only]

A Boolean value that declares whether the local player is underage. Some Game Center features are disabled if the local player is underage. Your game can also test this property if it wants to disable some of its own features based on the player’s age.


Implementation
    public function get isUnderage():Boolean
Method Detail
authenticate()method
public function authenticate($callback:Function):void

Your game should authenticate the player as early as possible after launching, ideally as soon as you can present a user interface to the player. For example, your game may be launched because the player accepted an invitation to join a match or to take a turn in a turn-based match, so you want your game to authenticate the player and process the match invitation as quickly as possible.

Parameters

$callback:Functionfunction($isAuthenticated:Boolean, $error:String):void

deleteSavedGame()method 
public function deleteSavedGame($name:String, $callback:Function):void

Deletes a specific saved game file.

Parameters

$name:String — A string that identifies the saved game data to be deleted.
 
$callback:Functionfunction($error:String):void is called when the request completes. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil, indicating a successful delete.

fetchSavedGames()method 
public function fetchSavedGames($callback:Function):void

Retrieves all available saved games. When there is more than one saved game with the same name, a conflict occurs. The app must determine which saved game file is correct and call resolveConflicts method.

Parameters

$callback:Functionfunction($savedGames:Vector.<SavedGame>, $error:String):void is called when the request completes. $savedGames is an array of SavedGame objects containing the retrieved games. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

loadDefaultLeaderboardId()method 
public function loadDefaultLeaderboardId($callback:Function):void

Loads the category identifier for the local player’s default leaderboard.

Parameters

$callback:Functionfunction($leaderboardId:String, $error:String):void is called when the request completes. $leaderboardId is the category ID string for the local player’s default leaderboard. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

loadRecentPlayers()method 
public function loadRecentPlayers($callback:Function):void

Returns an array of players the local player recently played with or any players that are on the local player's legacy friends list.

Parameters

$callback:Functionfunction($recentPlayers:Vector.<Player>, $error:String):void is called after the recent player list has been loaded. $recentPlayers is an array of players that the local player has recently played with. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil. Possible errors are networking issues or unauthenticated player.

observeAuthentication()method 
public function observeAuthentication($callback:Function):void

Watch user authentication status. whenever authentication status changes, the callback function will be called. when the callback is called, you should check for the GameCenter.localPlayer.isAuthenticated value.

Parameters

$callback:Functionfunction():void

onStatus()method 
override protected function onStatus(e:StatusEvent):void

Parameters

e:StatusEvent

resolveConflicts()method 
public function resolveConflicts($savedGames:Array, $gameData:String, $callback:Function):void

Resolves any conflicting saved games. This method takes an array of SavedGame objects that contain conflicting saved game files and creates a new array that contains the resolved conflicts. All saved game conflicts are resolved and added to the savedGames array in the completion handler. Call this method separately for each set of saved game conflicts. For example, if you have multiple saved game files with the name of "savedgame1" and "savedgame2", you need to call this method twice—once with an array containing the GKSavedGame objects with the "savedgame1" name and once for the "savedgame2" objects. All saved game conflicts are resolved asynchronously.

Parameters

$savedGames:Array — An array of SavedGame objects containing the conflicting saved games to be deleted.
 
$gameData:String — A String that contains the saved game data.
 
$callback:Functionfunction($savedGames:Vector.<SavedGame>, $error:String):void is called when the request completes. $savedGames is An array of SavedGame objects containing a saved game list with all conflicts contained in the conflictingSavedGames parameter resolved. If there are any conflicting saved game files that were not in the conflictingSavedGames parameter, these objects will automatically be appended to the end of the savedGames array. For example, if there are five saved game files with the same name, but only three are in the conflictingSavedGames array, this array will contain the resolved saved game file and the two unresolved files. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

saveGame()method 
public function saveGame($name:String, $gameData:String, $callback:Function):void

Saves game data under the specified name.

Parameters

$name:String — A string that identifies the saved game data.
 
$gameData:String — A String that contains the saved game data.
 
$callback:Functionfunction($game:SavedGame, $error:String):void is called when the request completes. $game is a SavedGame object containing saved game information for the saved data. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.

setDefaultLeaderboardId()method 
public function setDefaultLeaderboardId($leaderboardId:String, $callback:Function):void

Sets the default leaderboard for the current game. The default leaderboard is configured in App Store Connect as part of configuring your game’s leaderboards. All players normally start with this leaderboard as the default leaderboard. Calling this method changes the default leaderboard only for the local player.

Parameters

$leaderboardId:String — The identifier of the leaderboard to be set as the default leaderboard.
 
$callback:Functionfunction($error:String):void is called when the request completes. $error If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil.