Social Gaming with Clay.io

So the other day I finished creating a Christmas game for my family and friends and I posted the link to Facebook. Everybody seemed to enjoy it, but the only way they could share their high scores was by commenting in Facebook. They wanted to have some sort of official leaderboard instead. Once again, I didn’t have the desire nor the time to go down the road of reinventing the wheel, so I looked around for a strong JavaScript social gaming API.

After surveying the field I decided to use Clay.io. I picked it for the following reasons:

  • It is free to use if your game is free
  • It has a marketplace, but you are not obliged to feature your game there
  • The game can be hosted on your own server or the hosting/cloud service you use – it doesn’t have to be uploaded to Clay.io
  • You can set it up so that players only have to log in if they want to use the social gaming functions you enable
  • The out of the box functionality and look and feel is attractive and professional, but can be customised
  • It’s quick and easy to set up and implement

Even if you are hosting the game yourself, you still create a game record on Clay.io. This gives you a unique key for your game, so that you can associate the API functions you include with the correct game in your Clay account. You then just include a brief script (which is customised based on the functions you want to include) on the initial html page and then include simple snippets of code to activate the functions you need at the appropriate points in your game.

Within 15 minutes I had a working solution using the default look and feel of the Clay UI:

Snowthrow Leaderboard

Unfortunately in my haste to get this new functionality out to everybody, I neglected to pay enough attention to the game settings on Clay.io. The default behaviour for Clay is for the login/sign up screen to appear as soon as it can once the API has downloaded. Because I hadn’t changed this, my players were getting the login screen appearing even if they had no intention of using the leaderboard function. To make it even more annoying, if it was a bit slow in loading it would sometimes appear after they had started playing and interrupt the action. If you want the login/sign up screen to appear only when a social gaming function is used, you have to explicitly set this on the game settings page on Clay.io. Once this was done it worked fine – players who weren’t interested in the leaderboard didn’t see it at all, while players who wanted to post their scores would be prompted to sign up or log in the first time they tried to post a score.

Although at the moment Clay is only providing leaderboard functionality in my game, now it is in place there is plenty of scope for adding other features in future, such as achievements or challenges. I’ll add further posts on these functions if I get around to implementing them.

This entry was posted in Games, HTML5 and tagged , , , , . Bookmark the permalink.

Leave a reply