How to make a Facebook game




56,815 visits, 229,599 views



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Integrating the Facebook plugin

Now you have a basic Facebook game or app running on Facebook. Using the Facebook object in Construct 2, you can integrate with Facebook's features.

First of all, drop in the Facebook object to your game. In the properties bar, you need to enter your App ID.

You can get the App ID from the settings page earlier.

If you want to publish hi-scores on Facebook, also enter your App Secret. Do not enter the App Secret if you aren't going to use hi-scores! Entering your app secret is bad practice, but it is necessary to get the hi-scores system to work.

Adding Facebook features

You need to use the Facebook plugin's Log in action to enable integration. You cannot do this automatically: have a button saying "Log in" that the user must click. This will open a popup window and Facebook will request if the user wants to let the app access your account. They have to click Allow to log in.

The user can keep using your app if they are not logged in, but the Facebook plugin won't be able to do anything.

The permissions that the login screen asks the user to approve depends on what you set in the Log In action.

An important point is the fewer permissions you request from the user, the more likely they are to allow. In other words, do not ask for permissions you don't definitely need. Users are prone to avoiding logging in to apps that ask too much.

Here's what the Facebook plugin can do depending on permissions:

No permissions (both set to None)

- You can still get the user's name (e.g. to say "Welcome back, Joe Bloggs!")

- You can use the Prompt to share link, Prompt wall post, and Prompt to share this app actions. These bring up popup windows which the user can OK or cancel. For many games and apps, this is enough - you don't need to request any permissions at all for that!

Publish to stream permission

- You can do all of the above, and use the Publish wall post and Publish link actions. These instantly publish without prompting the user. You should be very careful not to annoy the user or they will ban your application. Always get the user to approve the action, and publish as little as possible.

In fact, this permission is not recommended. It is probably always better to use the Prompt actions which require no permissions, since the user controls what is written and can cancel it. However, the permission is provided in case it is useful to some apps.

Publish scores permission

- You of course get the 'no permissions' features, but you can also use the Scores API.

- This means using Publish score, Request hi-score board and other features. The picture of the login dialog above for Space Blaster shows what the login dialog looks like for this: it requests "Publish games and app activity".

You must also enter your App Secret to use the Scores features. But don't enter your App Secret if you're not using Scores!

Facebook events

The Facebook object has some conditions that can help you determine the state of the user.

Is ready is true if the Facebook object is ready to be used. If it is not ready, the Facebook features are still being loaded. You can't use the Log in action until the Facebook object is ready.

On user logged in triggers after the user clicks Allow on the login screen opened by the Log in action. However, the user's name is not yet available - it will follow shortly.

On user logged in also triggers if the user re-visits your app later, and their login is remembered. It also triggers again for each layout you go to, on the start of the layout. (This is helpful if the user returns to your title screen - the event still triggers.)

On name available triggers a moment after On user logged in. Now the user's name is set, which you can access via the Facebook object's expressions. These expressions will be empty before this triggers.


  • Order by
Want to leave a comment? Login or Register an account!
  • hi!

    Is there a plugin , same as instant games in c3 , for construct2 , to make games for facebook instant games?