Package | com.myflashlab.air.extensions.gameCenter |
Class | public class LocalPlayer |
Inheritance | LocalPlayer Player 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.
Property | Defined By | ||
---|---|---|---|
alias : String [read-only]
A string chosen by the player to identify themselves to other players. | Player | ||
displayName : String [read-only]
A string to display for the player. | Player | ||
guestIdentifier : 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 | ||
playerID : String [read-only]
A unique identifier associated with a player. | Player |
Method | Defined 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 | ||
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 | ||
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 | ||
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 |
Method | Defined By | ||
---|---|---|---|
onStatus(e:StatusEvent):void [override] | LocalPlayer |
isAuthenticated | property |
isAuthenticated:Boolean
[read-only] A Boolean value that indicates whether a local player is currently signed in to Game Center.
public function get isAuthenticated():Boolean
isUnderage | property |
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.
public function get isUnderage():Boolean
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:Function — function($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:Function — function($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:Function — function($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:Function — function($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:Function — function($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:Function — function():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:Function — function($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:Function — function($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:Function — function($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.
|