This tutorial will guide you on how to make your own custom leaderboard as well as posting to facebook and twitter using Clay.io .
Update: November 27th 2013:
There was an issue at the end with expvalue.set string. In order to fix the command error at the end of the capx file, Set another condition (event) to trigger once while true when timer=0. This prevents the callback from spamming the clay.io website. Apologies for the late replies on this bug
To view a sample of how this system works check out Spirit Masters: on the clay site Spirit Masters On Clay . The game is also availible on android by Clicking here
If youd like to just view the capx file download it below
click here to download the capx file
Step 1 (Register an account):
First you must have a clay account visit the site to register. clay.io
Step 2 (Game creation general preparation):
Once your registered login to the clay website and click on the developers tab at the top right. Press add a new game (your game does not have to be complete nor compiled to do this) Choose a subdomain pricing etc and press add game.
You will now have a game tab under your developers tab.
before you do anything.... Press the settings button on the clayio website of your game and copy the api key and paste it to your clayio object in construct 2. image shown below
Step 3 (Creating the leaderboards in clay):
Press leaderboards on the claysite and click on add leaderboards to add a leaderboard to your game. Name it anything youd like and make sure you know your ID which is used in construct 2.
Step 4 (Posting a score to clay in construct 2)
The capx file given up has instructions on how to do everything i will explain as well on how things work.
Create a text object and name it leaderboards. This will be where all your scores are viewed overal when players post there scores. As well create a text object that shows the score earned.
Next figure out how players will complete there game to earn a score. In the capx example when you touch the green spirit a score is given and posted to clay.io
Your (Player Score:) in the clay window is where the global variable will be placed that counts the score earned. (Player Name:) should be left blank. Lastly (Leaderboard ID) is found in the leaderboards section on the clay site mentioned step 3.
Step 5 (Fetch leaderboards)
To create your own custom leaderboards the fetch leaderboard event must be used.
Create an object or a text that when players touch or press the object the scores appear on the leaderboard text object explained on step 4.
Event: On touched (image) > Sub event (Clayio ready) > Action (Fetch leaderboard object)
Insert your leaderboard id, as well as anything else you would like to customize.
Scores From: (choose wheter players view scores from all or from clay.io friends, or there own personal earned scores)
Number of Scores: (How many scores should be viewed in the leaderboard)
after creating the fetch leaderboard event next up is what happens after the scores are fetched.
Step 6 (Leader board scores fetched)
Create an event > Leaderboard scores fetched > add another condition for a loop > Start index 0 End index: Clayio.leaderboardscorecount shown above.
Next up Create an action for the leaderboard text object > append text >
Clayio.LeaderboardName(loopindex) : used for viewing names of those who earned the score.
Clayio.LeaderboardScore(loopindex): used for viewing the scores earned.
And thats basically it on how to create the leaderboard using clay.io If you would like to create a rank system for your leaderboard as well as how to post to facebook and twitter download the capx file which will explain the steps.