Please note that Playtomic supports a lot of features, and I have not yet added them all into my "Davetomic" extension. I'm adding them as I use them, but it is rather simple to add so if you want me to add something just say so (so long as it is supported by Playtomic).
I've put together a little "Davetomic" pack you can download here: http://cl.ly/041r3u1A1a3N351o3o0A
Edit: Updated GEX found here: http://cl.ly/1L2h1b033W2l2q3r1E2m
Davetomic JS script is the same, but this updated file includes all of the currently supported functions in the GEX (was previously missing
Davetomic_submitscore()) and an updated version of the Playtomic API.
It has the extension GEX, and the two scripts inside the extension. One script is the Playtomic API (playtomic.js) and the other is the proxy script I wrote to use the API in GM (Davetomic.js). You should only need the GEX, but I have included the others for informational purposes, or in case you want to play with the scripts yourself (feel free).
You need to start by setting up an account at http://www.playtomic.com and then creating a game in that account.
Add the extension to your GMHTM5 project in the usual way.
On game load, call the function Davetomic_init(SWFID,"guid","apikey" ). The three arguments are given to you when you create your game in your playtomic account.
Calling this function sets up the other functions, and also logs a "view", so you can see how many people loaded up your game.
To submit a score, use the function: Davetomic_submitscore(pname, pscore, table)
pname is the player's name. pscore is their score. table is the name of the high score table. So if you had multiple highscore boards in the game, this would be the name of each board. Just make it up, ie "highscores". If it doesn't exist, it is created.
To show scores is a little more complicated. I'm not sure if it's possible to pass a JS array to GM, so I've made the script convert it into a format I'm familiar with: "Name1|Score1|Name2|Score2|Name3|Score3|" .
Start by calling the script Davetomic_getscores(table). table is the name of the highscore table used when submitting.
This function calls my secondary function crunchscores() which then converts it into the format I like. Unlike with my Davescores example, the game doesn't freeze when waiting for a response. That means you have to poll for it, checking a few times a second to see if the scores have been returned yet (Technically a callback function should be used, but I'm not sure how to trigger this in GM from an external script, or if it's even possible). You do this with Davetomic_pollscores(). This function returns "" if the scores are not ready, or "Name1|Score1|Name2|Score2|Name3|Score3|" etc if the scores are ready (so check for blank string until it is not blank, say, at intervals of 15 steps or so).
I use this GML script to separate them:
It assigns each section between |'s into the array explodearray. I wrote it many years ago so I'm sure it could be improved but it works.
Hopefully this is enough for you to get scores working. After initialising the Playtomic API, it also reports back every 30 seconds with any updated information. If you don't call any other functions then it just pings to report how long each user plays the game for. So from this basic setup, you get views, play time, and highscore boards.
The Playtomic API is outlined here: https://playtomic.com/api/html5
As far as I can tell, everything should be possible in GM, but I just haven't implemented it all.
Functions I have implemented:
Hopefully this helps you to get it all working, but if you need help feel free to ask. I haven't covered the extra functions but I think the Playtomic API documentation covers it pretty well. Good luck
Edited by Dangerous_Dave, 25 May 2012 - 10:26 AM.