Class: FacebookInstantGamesLeaderboard

Phaser. FacebookInstantGamesLeaderboard

This class represents one single Leaderboard that belongs to a Facebook Instant Game.

You do not need to instantiate this class directly, it will be created when you use the getLeaderboard() method of the main plugin.


new FacebookInstantGamesLeaderboard(plugin, data)

Parameters:
Name Type Description
plugin Phaser.FacebookInstantGamesPlugin

A reference to the Facebook Instant Games Plugin.

data any

An Instant Game leaderboard instance.

Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 11)

Extends

Members


contextID :string

The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context.

Type:
  • string
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 64)

entryCount :integer

The total number of player entries in the leaderboard. This value defaults to zero. Populate it via the getEntryCount() method.

Type:
  • integer
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 73)

name :string

The name of the leaderboard.

Type:
  • string
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 55)

playerScore :LeaderboardScore

The players score object. This value defaults to null. Populate it via the getPlayerScore() method.

Type:
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 83)

plugin :Phaser.FacebookInstantGamesPlugin

A reference to the Facebook Instant Games Plugin.

Type:
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 37)

ref :any

An Instant Game leaderboard instance.

Type:
  • any
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 46)

scores :Array.<LeaderboardScore>

The scores in the Leaderboard from the currently requested range. This value defaults to an empty array. Populate it via the getScores() method. The contents of this array are reset each time getScores() is called.

Type:
Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 93)

Methods


addListener(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 111)
Returns:

this.

Type
Phaser.Events.EventEmitter

destroy()

Removes all listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 42)

emit(event [, args])

Calls each of the listeners registered for a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

args * <optional>
<repeatable>

Additional arguments that will be passed to the event handler.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 86)
Returns:

true if the event had listeners, else false.

Type
boolean

eventNames()

Return an array listing the events for which the emitter has registered listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 55)
Returns:
Type
array

getConnectedScores()

Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players.

The data is requested in an async call, so the result isn't available immediately.

When the call completes this Leaderboard will emit the getconnectedscores event along with an array of LeaderboardScore entries and the name of the Leaderboard.

Since: 3.16.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 271)
Returns:

This Leaderboard instance.

Type
Phaser.FacebookInstantGamesLeaderboard

getEntryCount()

Fetches the total number of player entries in the leaderboard.

The data is requested in an async call, so the result isn't available immediately.

When the call completes this Leaderboard will emit the getentrycount event along with the count and name of the Leaderboard.

Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 107)
Returns:

This Leaderboard instance.

Type
Phaser.FacebookInstantGamesLeaderboard

getPlayerScore()

Gets the players leaderboard entry and stores it in the playerScore property.

The data is requested in an async call, so the result isn't available immediately.

When the call completes this Leaderboard will emit the getplayerscore event along with the score and the name of the Leaderboard.

If the player has not yet saved a score, the event will send null as the score value, and playerScore will be set to null as well.

Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 189)
Returns:

This Leaderboard instance.

Type
Phaser.FacebookInstantGamesLeaderboard

getScores( [count] [, offset])

Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard.

The data is requested in an async call, so the result isn't available immediately.

When the call completes this Leaderboard will emit the getscores event along with an array of LeaderboardScore entries and the name of the Leaderboard.

Parameters:
Name Type Argument Default Description
count integer <optional>
10

The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query.

offset integer <optional>
0

The offset from the top of the leaderboard that entries will be fetched from.

Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 230)
Returns:

This Leaderboard instance.

Type
Phaser.FacebookInstantGamesLeaderboard

listenerCount(event)

Return the number of listeners listening to a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 75)
Returns:

The number of listeners.

Type
number

listeners(event)

Return the listeners registered for a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 64)
Returns:

The registered listeners.

Type
array

off(event [, fn] [, context] [, once])

Remove the listeners of a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 151)
Returns:

this.

Type
Phaser.Events.EventEmitter

on(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 98)
Returns:

this.

Type
Phaser.Events.EventEmitter

once(event, fn [, context])

Add a one-time listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 124)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeAllListeners( [event])

Remove all listeners, or those of the specified event.

Parameters:
Name Type Argument Description
event string | symbol <optional>

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 165)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeListener(event [, fn] [, context] [, once])

Remove the listeners of a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 137)
Returns:

this.

Type
Phaser.Events.EventEmitter

setScore(score [, data])

Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player.

The data is requested in an async call, so the result isn't available immediately.

When the call completes this Leaderboard will emit the setscore event along with the LeaderboardScore object and the name of the Leaderboard.

If the save fails the event will send null as the score value.

Parameters:
Name Type Argument Description
score integer

The new score for the player. Must be a 64-bit integer number.

data string | any <optional>

Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to JSON.stringify.

Since: 3.13.0
Source: plugins/fbinstant/src/Leaderboard.js (Line 137)
Returns:

This Leaderboard instance.

Type
Phaser.FacebookInstantGamesLeaderboard

shutdown()

Removes all listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 31)