Enhance competitiveness by integrating leaderboards, allowing players to compare their scores and achievements.
Use this to determine if you can implement leaderboards for your game on the current platform.
Bridge.leaderboard.is_supported
Check if the leaderboard feature is supported on the platform.
Submit the player's score to the leaderboard to update their rank and position.
func _ready():
var options
match Bridge.platform.id:
"yandex":
options = {
"leaderboardName": "YOUR_LEADERBOARD_NAME",
"score": 42
}
Bridge.leaderboard.set_score(options, funcref(self, "_on_set_score_completed"))
func _on_set_score_completed(success):
print(success)
Retrieve the player's score from the leaderboard to display their current standing.
func _ready():
var options
match Bridge.platform.id:
"yandex":
options = {
"leaderboardName": "YOUR_LEADERBOARD_NAME"
}
Bridge.leaderboard.get_score(options, funcref(self, "_on_get_score_completed"))
func _on_get_score_completed(success, score):
print(success)
print(score)
Retrieve entries from the leaderboard, including the player's rank and score, to display a comprehensive leaderboard.
func _ready():
var options
match Bridge.platform.id:
"yandex":
options = {
"leaderboardName": "YOUR_LEADERBOARD_NAME",
"includeUser": true,
"quantityAround": 10,
"quantityTop": 10
}
Bridge.leaderboard.get_entries(options, funcref(self, "_on_get_entries_completed"))
func _on_get_entries_completed(success, entries):
print(success)
match Bridge.platform.id:
"yandex":
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))