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

An object that provides information about a player on Game Center. Every player account on Game Center is permanently assigned a unique player identifier string. Your game should use this string to store per-player information or to disambiguate between players. In most cases, Game Kit classes return player identifier strings to your game. For example, in a multiplayer match, the Match object’s playerIDs property contains an array of the player identifiers for all the players connected to the match.

To load information about a set of players, your game calls the Player.load method, passing in an array of identifier strings. The callback function is called after the player data is downloaded from Game Center. For performance and resource reasons, player objects returned do not include player photos. To load the photo associated with a player, call the player object’s loadPhoto method.

The concept of guest players is introduced in iOS 9. Guest players are treated exactly like authenticated players for Game Center multiplayer purposes. However, guest players cannot earn achievements, post to leaderboards, or participate in challenges. Create a guest player with the Player.createGuestPlayer method.



Public Properties
 PropertyDefined 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
  playerID : String
[read-only] A unique identifier associated with a player.
Player
Protected Properties
 PropertyDefined By
  _alias : String
Player
  _context : ExtensionContext
Player
  _displayName : String
Player
  _guestIdentifier : String
Player
  _id : String
Player
Public Methods
 MethodDefined By
  
createGuestPlayer($guestId:String):Player
[static] Creates a new guest player with the designated identifier.
Player
  
load($playerIDs:Vector.<String>, $callback:Function):void
[static] Loads information from Game Center about a list of players.
Player
  
loadPhoto($size:int, $callback:Function):void
Loads a photo of this player from Game Center.
Player
Protected Methods
 MethodDefined By
  
onStatus(e:StatusEvent):void
Player
Property Detail
_aliasproperty
protected var _alias:String

_contextproperty 
protected var _context:ExtensionContext

_displayNameproperty 
protected var _displayName:String

_guestIdentifierproperty 
protected var _guestIdentifier:String

_idproperty 
protected var _id:String

aliasproperty 
alias:String  [read-only]

A string chosen by the player to identify themselves to other players. A player’s alias is used when a player is not a friend of the local player. Typically, you never display the alias string directly in your user interface. Instead use the displayName property.


Implementation
    public function get alias():String
displayNameproperty 
displayName:String  [read-only]

A string to display for the player. The display name for a player depends on whether the player is a friend of the local player authenticated on the device. If the player is a friend of the local player, then the display name is the actual name of the player. If the player is not a friend, then the display name is the player's alias.


Implementation
    public function get displayName():String
guestIdentifierproperty 
guestIdentifier:String  [read-only]

A developer created string used to identify a guest player.


Implementation
    public function get guestIdentifier():String
playerIDproperty 
playerID:String  [read-only]

A unique identifier associated with a player. The player identifier should never be displayed to the player. Use it only as a way to identify a particular player.

Do not make assumptions about the contents of the player identifier string. Its format and length are subject to change.


Implementation
    public function get playerID():String
Method Detail
createGuestPlayer()method
public static function createGuestPlayer($guestId:String):Player

Creates a new guest player with the designated identifier. This method is used to create a new Player object for a guest player. Treat the guest player the same as a authenticated user in regards to matchmaking services.

Parameters

$guestId:String — A developer created String object used to identify the guest player.

Returns
Player — A new Player object.
load()method 
public static function load($playerIDs:Vector.<String>, $callback:Function):void

Loads information from Game Center about a list of players.

Below shows what parameters the callback function must have
     function($players:Vector.<Player>, $error:String):void
     {
         // $players:  is an array of Player objects, one per identifier. If an error occurred, this may be non-nil. In that case, the array holds whatever data Game Kit was able to retrieve for the requested players.
         // $error: If an error occurred, this error object describes the error. If the operation completed successfully, this is nil.
     }
     

Parameters

$playerIDs:Vector.<String> — A Vector of Strings, each a unique identifier for a Game Center player.
 
$callback:Function — is called when the player data is retrieved from Game Center.

loadPhoto()method 
public function loadPhoto($size:int, $callback:Function):void

Loads a photo of this player from Game Center.

Below shows what parameters the callback function must have
     function($player:Player, $path:String, $error:String):void
     {
         // $player: is a reference to the object which initiated this method.
         // $path: is an image for the player. If an error occurred, this may still be non-nil. In this case, the image reflects an image cached by Game Kit on the device.
         // $error: If an error occurred, this error object describes the error. If the operation completed successfully, this is nil.
     }
     

Parameters

$size:int — A constant that determines the size of the photo to load. PhotoSize.SMALL or PhotoSize.NORMAL
 
$callback:Function — is called when the player data is retrieved from Game Center.

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

Parameters

e:StatusEvent