Using PlayFab Service in Construct 2

  • 8 favourites


Attached Files

The following files have been attached to this tutorial:



Download now 179.69 KB


2,915 visits, 5,950 views


This tutorial hasn't been translated.


Step 3 - Prepare your project

Let's create a blank project. Then import previous js file into your project.

Now let's add the following plugin into your project :

- Browser

- Function

Also add the following object into your layout :

- 1 Input Text Box

- 1 Button

- 2 Text

Place it the way you like.

Step 4 - Configuring project

Now let's create a new Event Sheet, name it "PlayFab" then add 3 global variables :

Set the TITLE_ID variable with your Game Title ID from PlayFab dashboard.

Write a On Start Layout condition and add Browser->Execute Javascript as an action.

Copy these line as the value :

    "var js = document.createElement('script');
    js.type = 'text/javascript'; 
    js.src = 'playfabclientapi.js';

Then create a new Function, name it LoginWithCustomId , also add Browser->Execute Javascript as an action.

Copy these line as the value :

    " var loginRequest = {
    	TitleId: '"&TITLE_ID&"',
    	CustomId: '"&Function.Param(0)&"',
    	CreateAccount: true
    var LoginCallback = function (result, error) {
    	if (result !== null) {
    	} else if (error !== null) {
    }; PlayFabClientSDK.LoginWithCustomID(loginRequest, LoginCallback); "

For the callback function (so we know whether the login success or fail), Create a new function named OnLoginWithCustomID, there are 2 condition for parameter 0 : "success" or "error". You can create these event to notify the login process :

Now let's move to the layout's event sheet. Include the "PlayFab" event sheet.

Create an event to indicate user's click on the button. Add Function->Call Function as an action. Set the parameter as below :

The last, let's set both variable Text UI to the variable

Let's run your project and see if it's work.

It's so simple isn't it?


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