Package | com.distriqt.extension.gameservices.leaderboards |
Interface | public interface Leaderboards extends flash.events.IEventDispatcher |
This interface defines the leaderboard functionality for the Game Services native extension.
All the functionality here can be accessed through the main GameServices class as below:
GameServices.service.leaderboards.[FUNCTION]
See also
Property | Defined By | ||
---|---|---|---|
isSupported : Boolean [read-only]
Whether the leaderboards functionality is supported on the current game service. | Leaderboards |
Method | Defined By | ||
---|---|---|---|
displayLeaderboardUI(leaderboardId:String):void
Displays a native UI to the user showing the specified leaderboard. | Leaderboards | ||
loadLeaderboards(forceReload:Boolean = false):void
Asynchronously loads the list of available leaderboards for the current game and user. | Leaderboards | ||
loadPlayerCenteredScores(leaderboardId:String, maxResults:int = 10, span:String, collection:String, forceReload:Boolean = false):void
Asynchronously loads the scores from the specified leaderboard centered around the current player. | Leaderboards | ||
loadPlayerScore(leaderboardId:String, span:String, collection:String):void | Leaderboards | ||
loadTopScores(leaderboardId:String, maxResults:int = 10, span:String, collection:String, forceReload:Boolean = false):void
Asynchronously loads the top scores from the specified leaderboard. | Leaderboards | ||
submitScore(leaderboardId:String, score:int, tag:String):void
Submit a score to a leaderboard for the currently signed in player. | Leaderboards |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when there was an error loading the scores for a leaderboard. | Leaderboards | |||
Dispatched when the player centered scores from a leaderboard have been loaded. | Leaderboards | |||
Dispatched when there was an error loading the player's leaderboard score. | Leaderboards | |||
Dispatched when the player's leaderboard score has been loaded. | Leaderboards | |||
Dispatched when there was an error loading the scores for a leaderboard. | Leaderboards | |||
Dispatched when the scores from a leaderboard have been loaded. | Leaderboards | |||
Dispatched when there was an error submitting a score to a leaderboard. | Leaderboards | |||
Dispatched when a score has been successfully submitted to a leaderboard | Leaderboards | |||
Dispatched when the top scores from a leaderboard have been loaded. | Leaderboards | |||
Dispatched when the displayed leaderboard UI is closed by the user. | Leaderboards | |||
Dispatched when there was an error loading the leaderboards. | Leaderboards | |||
Dispatched when the metadata about the leaderboards has been loaded. | Leaderboards |
isSupported | property |
isSupported:Boolean
[read-only]
Whether the leaderboards functionality is supported on the current game service.
public function get isSupported():Boolean
displayLeaderboardUI | () | method |
public function displayLeaderboardUI(leaderboardId:String):void
Displays a native UI to the user showing the specified leaderboard.
If you want to display the UI showing all the leaderboards, simply
pass an empty string (""
) as the leaderboardId
or call this function with no parameters.
Parameters
leaderboardId:String — The id of the leaderboard to query. This will be retrieved from the loadLeaderboards request or you can hard code from your game application setup.
|
loadLeaderboards | () | method |
public function loadLeaderboards(forceReload:Boolean = false):void
Asynchronously loads the list of available leaderboards for the current game and user.
This will fire a LeaderboardEvent.LEADERBOARDS_LOADED
when the load is complete, and the event will contain an array of Leaderboard objects.
Parameters
forceReload:Boolean (default = false ) — Forces an update of the data if true otherwise will use the internally cached version.
|
See also
The following shows the process of loading and processing the leaderboards using the Google Play Game Services.
try { GameServices.init( _devKey ); if (GameServices.isSupported) { GameServices.service.addEventListener( GameServicesEvent.INITIALISED, gameServices_initialisedHandler ); GameServices.service.addEventListener( GameServicesEvent.SIGN_IN_SUCCESS, gameServices_signInSuccessHandler ); GameServices.service.leaderboards.addEventListener( LeaderboardEvent.LEADERBOARDS_LOADED, gameServices_leaderboardsLoadedHandler ); GameServices.service.leaderboards.initialiseService( Service.GOOGLE_PLAY_GAME_SERVICES, _googlePlayClientID ); } } catch (e:Error) { } ... private function gameServices_initialisedHandler( event:GameServicesEvent ):void { GameServices.service.signIn(); } private function gameServices_signInSuccessHandler( event:GameServicesEvent ):void { GameServices.service.leaderboards.loadLeaderboards(); } private function gameServices_leaderboardsLoadedHandler( event:LeaderboardEvent ):void { var boards:Array = event.data; for each (var board:Leaderboard in boards) { trace( "["+board.id+"] "+board.displayName ); } }
loadPlayerCenteredScores | () | method |
public function loadPlayerCenteredScores(leaderboardId:String, maxResults:int = 10, span:String, collection:String, forceReload:Boolean = false):void
Asynchronously loads the scores from the specified leaderboard centered around the current player. Returned will be details on the leaderboard along with the specified number of results on the leaderboard, with player information and scores.
Parameters
leaderboardId:String — The id of the leaderboard to query. This will be retrieved from the loadLeaderboards request or you can hard code from your game application setup.
| |
maxResults:int (default = 10 ) — The maximum number of results to return from this query.
| |
span:String (default = NaN ) — The time span for the query (see Leaderboard.TIME_SPAN_... )
| |
collection:String (default = NaN ) — The collection for the query (see Leaderboard.COLLECTION_PUBLIC or Leaderboard.COLLECTION_SOCIAL )
| |
forceReload:Boolean (default = false ) — Forces an update of the data if true otherwise will use the internally cached version and only update when necessary.
|
See also
loadPlayerScore | () | method |
public function loadPlayerScore(leaderboardId:String, span:String, collection:String):void
Parameters
leaderboardId:String | |
span:String (default = NaN )
| |
collection:String (default = NaN )
|
loadTopScores | () | method |
public function loadTopScores(leaderboardId:String, maxResults:int = 10, span:String, collection:String, forceReload:Boolean = false):void
Asynchronously loads the top scores from the specified leaderboard. Returned will be details on the leaderboard along with the specified number of results on the leaderboard, with player information and scores.
Parameters
leaderboardId:String — The id of the leaderboard to query. This will be retrieved from the loadLeaderboards request or you can hard code from your game application setup.
| |
maxResults:int (default = 10 ) — The maximum number of results to return from this query.
| |
span:String (default = NaN ) — The time span for the query (see Leaderboard.TIME_SPAN_... )
| |
collection:String (default = NaN ) — The collection for the query (see Leaderboard.COLLECTION_PUBLIC or Leaderboard.COLLECTION_SOCIAL )
| |
forceReload:Boolean (default = false ) — Forces an update of the data if true otherwise will use the internally cached version and only update when necessary.
|
See also
submitScore | () | method |
public function submitScore(leaderboardId:String, score:int, tag:String):void
Submit a score to a leaderboard for the currently signed in player. The score is ignored if it is worse (as defined by the leaderboard configuration) than a previously submitted score for the same player.
The meaning of the score value depends on the formatting of the leaderboard established in the developer console. Leaderboards support the following score formats:
tag
is a string value here however certain services limit the type
that can be used. So we suggest using only numeric characters for the tag value.
Parameters
leaderboardId:String — The id of the leaderboard to add this score to. This will be retrieved from a loadLeaderboards request or you can use a value from your game application setup.
| |
score:int — The score to submit
| |
tag:String — A tag to associate with this score (will be returned in leaderboard scores as the tag value)
|
leaderboard:playercenteredscores:error | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.PLAYERCENTEREDSCORES_ERROR
Dispatched when there was an error loading the scores for a leaderboard. The data field may contain more information.
leaderboard:playercenteredscores:loaded | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.PLAYERCENTEREDSCORES_LOADED
Dispatched when the player centered scores from a leaderboard have been loaded.
For this event the leaderboard
will be the leaderboard
information that was loaded and the data
will contain
an Array of LeaderboardScore
objects.
leaderboard:playerscore:error | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.PLAYERSCORE_ERROR
Dispatched when there was an error loading the player's leaderboard score.
This could be due to an issue with the leaderboard or that the player hasn't yet submitted any scores to the specified leaderboard.
leaderboard:playerscore:loaded | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.PLAYERSCORE_LOADED
Dispatched when the player's leaderboard score has been loaded.
data
will contain an array of one score object, being the players score.
leaderboard:scores:error | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.SCORES_ERROR
Dispatched when there was an error loading the scores for a leaderboard. The data field may contain more information.
leaderboard:scores:loaded | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.SCORES_LOADED
Dispatched when the scores from a leaderboard have been loaded.
For this event the leaderboard
will be the leaderboard
information that was loaded and the data
will contain
an Array of LeaderboardScore
objects.
leaderboard:submitscore:error | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.SUBMITSCORE_ERROR
Dispatched when there was an error submitting a score to a leaderboard. The data field may contain more information.
leaderboard:submitscore:success | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.SUBMITSCORE_SUCCESS
Dispatched when a score has been successfully submitted to a leaderboard
leaderboard:topscores:loaded | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.TOPSCORES_LOADED
Dispatched when the top scores from a leaderboard have been loaded.
For this event the leaderboard
will be the leaderboard
information that was loaded and the data
will contain
an Array of LeaderboardScore
objects.
leaderboard:ui:closed | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.UI_CLOSED
Dispatched when the displayed leaderboard UI is closed by the user.
leaderboards:error | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.LEADERBOARDS_ERROR
Dispatched when there was an error loading the leaderboards. The data field may contain more information.
leaderboards:loaded | Event |
com.distriqt.extension.gameservices.events.LeaderboardEvent
com.distriqt.extension.gameservices.events.LeaderboardEvent.LEADERBOARDS_LOADED
Dispatched when the metadata about the leaderboards has been loaded.