add leaderboard with clay.io

Get help using Construct 2

Post » Tue Mar 04, 2014 1:07 pm

hello can anyone tell me how i create a leaderboard using clay.io ?:O
B
5
S
1
Posts: 6
Reputation: 1,052

Post » Tue Mar 04, 2014 1:28 pm

You should take a look at their documentation on the C2 API.

Here is the part on leaderboards :
In Construct 2

Actions

Post Leaderboard Score

Name is optional, if specified, it will show up next to the score. If not specified, Clay.io will ask the player for his or her name
Score should be set to whichever variable (expression) you have the score stored to
Leaderboard ID is what you were given after creating the leaderboard on Clay.io
Post Encrypted Leaderboard Score
This requires a backend for your game, but you can have more secure high scores by sending an encoded JWT (JSON Web Token) that specifies the score. See http://clay.io/docs/encryption for further details

Show Leaderboard

Leaderboard ID is what you were given after creating the leaderboard on Clay.io
Time Frame is how far back in time you want to grab scores from
High Score can be set to individual (a single score per time they post a score), cumulative (each time they post a score it is added to their total score), or best (only use the best score from each player)
Sort is for the order of scores. Descending is highest to lowest, ascending is lowest to highest
Scores From can be All (scores from everyone who has played the game), Personal (just the current player's scores) or Friends (just the player's Clay.io and Facebook friends' scores)
Fetch Leaderboard
If you would like a more customized-looking score table, you can fetch the list of high scores and loop through them using a System -> For loop from 0 to Clayio.LeaderboardScoreCount. The options to fill in are identical to above

Hide Leaderboard
The leaderboard already has a close button and closing it is bound to the "esc" key, but you can also close it with this action

Conditions

Leaderboard Score Posted
This is called when a score is successfully posted to Clay.io. A good use for this condition is to display the leaderboard immediately after the score is posted.

Leaderboard Scores Fetched
This is called using the event "Fetch Leaderboard Scores" when they are successfully fetched

Expressions

LeaderboardScoreCount
The number of scores fetched using "Fetch Leaderboard Scores"

LeaderboardName
Use this in conjunction with a System -> For loop from 0 to Clayio.LeaderboardScoreCount to fetch high score names - it will look like this: Clayio.LeaderboardName(loopindex)

LeaderboardScore
Use this in conjunction with a System -> For loop from 0 to Clayio.LeaderboardScoreCount to fetch high score numeric scores - it will look like this: Clayio.LeaderboardScore(loopindex)

LeaderboardScoreMe
Use this in conjunction with a System -> For loop from 0 to Clayio.LeaderboardScoreCount to fetch high scores. Returns 1 if the current score was posted by the current player, 0 otherwise - it will look like this: Clayio.LeaderboardScoreMe(loopindex)

LeaderboardRank
Either the rank the player just achieved - or their highest rank if their score wasn't just posted (when using "Fetch Leaderboard Scores")

LeaderboardRankName
The name of the player playing (when using "Fetch Leaderboard Scores")

LeaderboardRankScore
The score the player just achieved - or their highest rank if their score wasn't just posted (when using "Fetch Leaderboard Scores")
B
17
S
8
G
4
Posts: 473
Reputation: 6,191


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 41 guests