Hi,
I have got a working solution. This will work only for leaderboard among friends. It will not show a world-wide leaderboard. This is because, if the call for scores is initiated from user, Fb will give only the user's friend's scores.
I think clay.io plugin should help if you want world wide leaderboard. Please check this tutorial if it helps:
https://www.scirra.com/tutorials/495/how-to-make-a-custom-leaderboard-and-more-using-clay
I haven't used clay.io, but, I store every user's score on my server and display the world leaders on a separate page.
Attached screenshot of events sheet.
Logic:
Create arrays to store High score data (I have used 2 arrays - one for name and one for score)
Create global variable for Array indexing. ('i" in my example)
1. Call "Request hi-score board"
2. Set the number of scores you need - 10 in my example
3. Use "On hi-score" to populate the arrays. Note that "On hi-score" is triggered once for each score record received. Hence if you ask 10 scores it will be triggered 10 times. For each trigger we are incrementing the index (i) and storing the data in the respective arrays.
4. After that we display the scoreboard in different text boxes. I used 20 of them.
IMPORTANT CHANGES TO BE MADE TO c2runtime.js
1. In FB.init add "Version": "v2.0",
2. js.src link change all.js --> sdk.js
3. RequestHiscores function def add '/v2.0/' after FB.api(
4. You have to update "channel.html" with point 2
These are for changes due to Facebook platform upgrade.
I have attached screenshots to illustrate all these points.
Possible improvements:
I think one array could be used... maybe
2. all the fb related changes may not be necessary
Food for thought....
If you have less than 10 friends who have played, then "On hi-scores" will be triggered exactly for the number of players only. It will not trigger all the times. So the array will be filled partially. (to be explored: What if we have more than 10 friends and we want to dynamically display the exact number of friends who play the game???)
Let me know if this helped.
I'll be glad, if some experts can offer tips on optimizing what i've done.
Cheers,
Capper