HTML5 (Javascript) Client Reference
Class achievements
Language: Javascript (HTML5)
The Achievements service. This class is used to update the progress of an achievement for the current user, and loading achievements of other users. All achievements have to be defined in the admin panel first.
Example
Refresh to get the user's current achievements and the progress of each:
Example
Load achivements for other users:
Example
Set the progress of the achievement "fiveinarow" to 2.
Properties | ||||
---|---|---|---|---|
|
||||
Methods | ||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
achievements.myAchievements
|
The list of achievements for the current user. You must call refresh() first to initialize this list.
achievements.addOnComplete
|
Add an OnComplete event handler that will be called every time an achievement is completed.
Arguments
onComplete:function(achievement) | |
The function to add. |
achievements.get
|
Get an achievement by id
Arguments
achievementId:string | |
Id of the achievement to get. |
achievements.load
|
Load the achivements for multiple users by their connectUserId
Arguments
userIds:string[] | |
The list of users to load achievements for. | |
successCallback:function(result) | |
Callback function that will be called with the loaded achievements. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
achievements.progressAdd
|
Adds the delta to the progress of the specified achievement
Arguments
achievementId:string | |
The id of the achievement to add to the progress for. | |
progressDelta:Number | |
The value to add to the progress. | |
successCallback:function(achievement) | |
Callback function that will be called when the operation has completed. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
achievements.progressComplete
|
Completes the specified achievement by setting the progress to the progress goal.
Arguments
achievementId:string | |
The id of the achievement to complete. | |
successCallback:function(achievement) | |
Callback function that will be called when the operation has completed. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
achievements.progressMax
|
Sets the progress of the specified achievement to the bigger value of the current value and the given value.
Arguments
achievementId:string | |
The id of the achievement to set the progress for. | |
progress:Number | |
The value to set the progress to, if it's bigger than the current value. | |
successCallback:function(achievement) | |
Callback function that will be called when the operation has completed. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
achievements.progressSet
|
Sets the progress of the specified achievement
Arguments
achievementId:string | |
The id of the achievement to set the progress for. | |
progress:Number | |
The value to set the progress to | |
successCallback:function(achievement) | |
Callback function that will be called when the operation has completed. | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs. |
achievements.refresh
|
Refresh the list of achievements.
Arguments
successCallback:function() | |
Callback function that will be called when the refresh is complete | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs |