Leaderboards

Enhance competitiveness by integrating leaderboards, allowing players to compare their scores and achievements.

Leaderboards Type

Type of leaderboards on the current platform.

Bridge.leaderboards.type
Type
Game Logic

not_available

Leaderboards are not available. Any leaderboard functionality must be disabled in the game.

in_game

Leaderboards are available.

The game must use the set_score method to set the player's score.

The game should display custom in-game leaderboards using the data from the get_entries method.

native

Leaderboards are available.

The game must use the set_score method to set the player's score.

The game should not display custom in-game leaderboards because leaderboards are displayed in the platform interface and the get_entries method does not work.

Setup

Setup leaderboards in the config file. For each leaderboard add an id. You can override which id is sent to the platform's native SDK.

{
    ...    
    "leaderboards": [
        {
            "id": "test_leaderboard", // use this id in game logic
            "<ANY_PLATFORM_ID_HERE>": "<OVERRIDED_ID_FOR_PLATFORM_HERE>"
        }
    ]
}

Set Score

Submit the player's score to the leaderboard to update their rank and position.

func _ready():
    var leaderboardId = "YOUR_LEADERBOARD_ID" # id that you specified in the config file
    var score = 42
    Bridge.leaderboards.set_score(leaderboardId, score, funcref(self, "_on_set_score_completed"))

func _on_set_score_completed(success):
    print(success)

Get Entries

Works only when Bridge.leaderboards.type = in_game

Retrieve entries from the leaderboard, including the player's rank and score, to display a custom leaderboard in the game.

func _ready():
    var leaderboardId = "YOUR_LEADERBOARD_ID" # id that you specified in the config file
    Bridge.leaderboards.get_entries(leaderboardId, funcref(self, "_on_get_entries_completed"))

func _on_get_entries_completed(success, entries):
    print(success)
    
    for entry in entries:
        print("ID: " + str(entry.id))
        print("Name: " + str(entry.name))
        print("Score: " + str(entry.score))
        print("Rank: " + str(entry.rank))
        print("Photo: " + str(entry.photo))

Last updated