🏆
Leaderboards
You need to create a leaderboard on your dashboard before proceeding. Make sure you set up automatic resets and prizes in the dashboard if needed.
Report scores from a user.
LevelId
is optional and can be any string to distinguish your levels. You do not need to individually create leaderboards for each level! Passing a LevelId
acts as a filter.What is a Level? You can use a
LevelId
if you want separate leaderboards for separate levels in your game, without having to create multiple leaderboards. Just use the same LevelId
to report the score and show the leaderboard.
This is fully optional.Unity
Cordova / Javascript
iOS
GameMaker
GalaxyClientAPI.ReportScore(new GalaxySDK.ClientModels.ReportScoreRequest {
Score = 500.0, //required
LeaderboardId = "leaderboard_id", //required
LevelId = "level_id", //optional
}, result => { }, error => { });
window.galaxy.ClientAPI.ReportScore({
leaderboard_id: 'leaderboard_id',
score: 1,
sub_section: "level_id" // optional
}, (result, error) => { })
GalaxySDK.shared.reportScore(leaderboardId: "leaderboard id", score: 500)
Galaxy_ReportScore(leaderboard_id, score_value, level_id?) //level_id is optional
Configure the leaderboard UI, reset behavior, and more in your dashboard.
Unity
Cordova / Javascript
iOS
GameMaker
The UI doesn't work in the Unity editor! Run on a real device to test.
//Show a combined UI for the default leaderboard full screen
GalaxyClientAPI.Controller.OpenLeaderboard(LeaderboardId: "leaderboard_id");
//Only show scores reported for level "level_id" and include ViewOptions
GalaxyClientAPI.Controller.OpenLeaderboard(
LeaderboardId: "leaderboard_id",
LevelId: "level_id",
Options: ViewOptions
);
//Overlay on the screen
window.galaxy.ShowLeaderboard({
leaderboard_id: 'leaderboard_id'
});
GalaxySDK.shared.show(leaderboardId: "leaderboard id")
Galaxy_LeaderboardShow(leaderboard_id)
Every
Open
call accepts an optional ViewOptions
parameter that can be used to customize the view. Here's a ViewOptions
example with defaults:new GalaxySDK.GalaxyController.ViewOptions {
Left = 0,
Top = 0,
Right = 0,
Bottom = 0,
HideCloseButton = false,
CloseButtonPosition = 0, //0 for left, 1 for right
OnClose = onClose //Action
}
A player record contains information about their score/rank on a specific leaderboard. If no
PlayerId
is passed, the current user is returned.Unity
Cordova / Javascript
iOS
GameMaker
GalaxyClientAPI.GetPlayerRecord(new GalaxySDK.ClientModels.GetPlayerRecordRequest {
LeaderboardId = "leaderboard_id", //required
LevelId = "level_id", //optional
PlayerId = "player_id" //optional
}, result => {
var playerRank = result.Record.Rank;
var playerScore = result.Record.Score;
}, error => { });
window.galaxy.ClientAPI.GetPlayerRecord({
leaderboard_id: 'Your Leaderboard Id',
}, (result, error) => {
var playerRank = result.record.rank;
var playerScore = result.record.score;
});
GalaxySDK.shared.getPlayerRecord(leaderboardId: "leaderboard id", playerId: nil) { record in
let playerRecord: LeaderboardRecord = record;
}
Galaxy_GetPlayerRecord(leaderboard_id, level?, player_id?, function(response){
show_message_async(response.record.rank) //Show ranking on leaderboard_id
})
Leave
level
blank if you don't use levels, and leave player_id
blank to get the current playerGalaxy_GetPlayerRecord(leaderboard_id,,, function(response){
show_message_async(response.record.rank) //Show ranking on leaderboard_id
})
Response
/// User records for the requested user.
public LeaderboardRecord Record;
Get the leaderboard data directly
Unity
Cordova / Javascript
GalaxyClientAPI.GetLeaderboard(new GalaxySDK.ClientModels.GetLeaderboardRequest {
LeaderboardId = "leaderboard_id",
Offset = 0,
Limit = 50,
LevelId = "level_id", //optional
}, result => {
var records = result.Records;
}, error => { });
window.galaxy.ClientAPI.GetLeaderboard({
leaderboard_id: 'Your Leaderboard Id',
level_id: 'Level Id' //optional
}, (result, error) => {
var records = result.records;
});
Response
/// User records for the requested user.
public List<LeaderboardRecord> Records;
Last modified 4mo ago