Packagecom.myflashlab.air.extensions.gameCenter
Classpublic class Achievement
InheritanceAchievement Inheritance flash.events.EventDispatcher

An object that communicates with Game Center about the local player’s progress toward completing an achievement. You can’t just add an achievement to your game programmatically. There are several steps that you must accomplish to add achievements to your game. Read official docs: https://developer.apple.com/documentation/gamekit/gkachievement?language=objc

By default, when an achievement is completed, GameKit displays a notification banner to the player. If your game wants to display its own achievement user interface, you can prevent the banner from being displayed by setting the showsCompletionBanner property of the achievement object to NO before reporting the player’s progress.



Public Properties
 PropertyDefined By
  identifier : String
[read-only] A string used to uniquely identify the specific achievement the object refers to.
Achievement
  isCompleted : Boolean
[read-only] A Boolean value that states whether the player has completed the achievement.
Achievement
  lastReportedDate : Date
[read-only] The last time that progress on the achievement was successfully reported to Game Center.
Achievement
  percentComplete : Number
A percentage value that states how far the player has progressed on this achievement.
Achievement
  player : Player
[read-only] A Player object used to identify the player who earned the achievement.
Achievement
  showsCompletionBanner : Boolean
A Boolean value that states whether a banner is displayed when the achievement is completed.
Achievement
Public Methods
 MethodDefined By
  
challengeCompose($msg:String, $players:Vector.<Player>, $callback:Function):void
Provides a challenge compose view controller with a preformatted message for the achievement and pre-selected Player objects.
Achievement
  
initNew($identifier:String, $player:Player = null):Achievement
[static] Initializes an achievement object for a specific player or pass null for $player param to initializes a new achievement object for the local player.
Achievement
  
load($callback:Function):void
[static] Loads previously submitted achievement progress for the local player from Game Center.
Achievement
  
report($achievements:Vector.<Achievement>, $challenges:Vector.<Challenge>, $callback:Function):void
[static] Reports a list of achievements and limits the challenges those achievements may complete.
Achievement
  
reset($callback:Function):void
[static] Resets all achievement progress for the local player.
Achievement
  
selectChallengeablePlayers($players:Vector.<Player>, $callback:Function):void
Finds the subset of players that can earn an achievement.
Achievement
Property Detail
identifierproperty
identifier:String  [read-only]

A string used to uniquely identify the specific achievement the object refers to.


Implementation
    public function get identifier():String
isCompletedproperty 
isCompleted:Boolean  [read-only]

A Boolean value that states whether the player has completed the achievement.


Implementation
    public function get isCompleted():Boolean
lastReportedDateproperty 
lastReportedDate:Date  [read-only]

The last time that progress on the achievement was successfully reported to Game Center.


Implementation
    public function get lastReportedDate():Date
percentCompleteproperty 
percentComplete:Number

A percentage value that states how far the player has progressed on this achievement.


Implementation
    public function get percentComplete():Number
    public function set percentComplete(value:Number):void
playerproperty 
player:Player  [read-only]

A Player object used to identify the player who earned the achievement.


Implementation
    public function get player():Player
showsCompletionBannerproperty 
showsCompletionBanner:Boolean

A Boolean value that states whether a banner is displayed when the achievement is completed. When an achievement is completed and the value of this property is true, a notification banner is displayed to the player to inform them of the completed achievement. If the value of this property is false, there is no visual indication that the achievement is completed. Your game should set this property to false to provide its own visual indicator that the achievement was earned. The default value is false.


Implementation
    public function get showsCompletionBanner():Boolean
    public function set showsCompletionBanner(value:Boolean):void
Method Detail
challengeCompose()method
public function challengeCompose($msg:String, $players:Vector.<Player>, $callback:Function):void

Provides a challenge compose view controller with a preformatted message for the achievement and pre-selected Player objects.

Below shows what parameters the callback function must have
     function($achievement:Achievement, $didIssueChallenge:Boolean, $sentPlayerIDs:Array):void
     {
         // $achievement: is a reference to the object which initiated this method.
         // $didIssueChallenge: is a Boolean variable designating if the challenge was sent out.
         // $sentPlayerIDs: An array of playerIDs that the challenge was sent to.
     }
     

Parameters

$msg:String — The message that is sent to other players. This message can be edited by the player.
 
$players:Vector.<Player> — An array of Player objects that contains the player identifiers that the challenge is to be sent to.
 
$callback:Function — callback function that determines if a challenge has been issued and if so, who it is sent to.

initNew()method 
public static function initNew($identifier:String, $player:Player = null):Achievement

Initializes an achievement object for a specific player or pass null for $player param to initializes a new achievement object for the local player.

Your game initializes a new achievement object for a specific player only when it has not previously reported progress for that achievement. Only use this method to submit a participant’s achievement when ending a turn-based match.

Your game initializes a new achievement object only when it has not previously reported progress for that achievement. If your game has previously reported progress on an achievement, you should first retrieve the current progress by calling the Achievement.load() method.

Parameters

$identifier:String — A string that matches the identifier string for an achievement you created for your game in App Store Connect.
 
$player:Player (default = null) — A Player object that identifies the player associated with the specified achievement.

Returns
Achievement — An initialized achievement object, or null if an error occurred.
load()method 
public static function load($callback:Function):void

Loads previously submitted achievement progress for the local player from Game Center.

Below shows what parameters the callback function must have
     function($achievements:Vector.<Achievement>, $error:String):void
     {
         // $achievements: A array of loaded Achievement objects.
         // $error: If an error occurred, this error object describes the error.
     }
     

Parameters

$callback:Function — will be called when the download is completed.

report()method 
public static function report($achievements:Vector.<Achievement>, $challenges:Vector.<Challenge>, $callback:Function):void

Reports a list of achievements and limits the challenges those achievements may complete.

Below shows what parameters the callback function must have
     function($error:String):void
     {
         // $error: will be null if the operation was completed successfully.
     }
     

Parameters

$achievements:Vector.<Achievement> — An array of Achievement objects that represents all achievements that are being reported.
 
$challenges:Vector.<Challenge> — (can be set to null) An array of Challenge objects that represents the limited challenges that are associated with the reported achievements. If an error occurred, this parameter may be non-nil, in which case the array holds whatever challenge information Game Kit was able to fetch.
 
$callback:Function — will be called when the download is completed.

reset()method 
public static function reset($callback:Function):void

Resets all achievement progress for the local player. Calling this class method deletes all progress towards achievements previously reported for the local player. Hidden achievements that were previously visible are now hidden again.

Below shows what parameters the callback function must have
     function($error:String):void
     {
         // $error: will be null if the operation was completed successfully.
     }
     

Parameters

$callback:Function — will be called when the reset action is completed.

selectChallengeablePlayers()method 
public function selectChallengeablePlayers($players:Vector.<Player>, $callback:Function):void

Finds the subset of players that can earn an achievement.

Below shows what parameters the callback function must have
     function($achievement:Achievement, $players:Vector.<Player>, $error:String):void
     {
         // $achievement: is a reference to the object which initiated this method.
         // $players: is an array of Player objects representing the players in the original array that are able to complete the challenge. If an error occurred, this parameter may be non-nil, in which case the array holds whatever achievement information Game Kit was able to fetch.
         // $error: If an error occurred, this object describes the error. If the operation completed successfully, this value is nil.
     }
     

Parameters

$players:Vector.<Player> — An array of Player objects containing a list of players. The list of players is used to find those players that are eligible to earn the achievement.
 
$callback:Function — will be called when the download is completed.