[SOLVED] PlayCanvas and Facebook instant games

Hello! We are currently building for FIG using playcanvas - we love the engine!

However, we’re struggling to find clear information on how we would go about implementing the simple friends-list high score tracking found in, amongst other games, Master Archer (the one that occurs through the FIG api, not in the game itself). The facebook documentation is less than enlightening, and we can’t find anything on the PlayCanvas forums or tutorial sections.

Is anyone aware of any better documentation, guides or best of all, sample code? Our game is almost ready to go but for this frustration. I’m almost certain that this shouldn’t be as difficult as we’re finding it, so we must have missed something simple and critical?

Thank you for any help!

I believe Instant Games are in closed beta at Facebook. Can you see this page? https://developers.facebook.com/docs/games/instant-games if not that means you need to get access to it from Facebook which I don’t know if they give out to people openly yet.

We are in the closed beta, and do have access. The issue we are having is that there is no clear or obvious examples of the functionality we require - the one example project FB provides is for an async tic tac toe game launched through messenger chat invites.

Our game is playable, and can just about launch - its the score tracking/play button example loop that we’re after: https://imgur.com/a/n8wvS
We cannot find any clear reference to it whatsoever. Its been used in a lovely simple and effective manner in Master Archer, and we were hoping you may have clearer insight into exactly what/where we should be looking.

Master Archer used the setScore method on the facebook instant API. It just did this:

FBInstant.endGameAsync().then(function () {
      // ....

Looking at their docs right now it looks like they removed that function:

Version 3.0:
(Removed) FBInstant.game.setScore() We are now providing a flexible platform that allows the developer to keep a customizable leaderboard using their own backend.

You might want to get in touch with them about how to go about doing a leaderboard now. It seems to me that you have to use your own server to store leaderboards now possibly…

This is great actually - I’m assuming you used a version of the SDK below 2.1? That’s still an option available to us, so we’ll likely take that route.

Just to confirm, you didn’t have to call anything in the API to make that score overlay appear, beyond the setScore method? And you called that in PlayCanvas code, not in the index.html?

Thanks for all your help on this, its a deployment method we’re really not used to so all information is incredibly useful.

Yeah all the leaderboard stuff is through Facebook - the overlay is done by them in the Messenger app. I don’t know if they do that anymore but we used version 1.X or something if I remember correctly…

Great, thank you! I understand if this is not possible, but if there was anyway you could share a screenshot of the index.html/the place where you trigger the setScore in a little more context to enteagd@gmail.com, that would be incredible - do understand if this isn’t possible however.

An official step by step guide for FIG with playcanvas (even a simple cube clicker example project) would be a really amazing thing for the future, btw. I think the platform’s going to be big and PlayCanvas is a strong fit for it!!


I’ll PM you some code.