Phaser API Documentation

  Version: 
setScore(score, [data])

Description:

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 arguments 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.

Returns:
Description:

This Leaderboard instance.

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