Using Xbox Live in UWP apps

15

Stats

8,972 visits, 11,411 views

Tools

Translations

This tutorial hasn't been translated.

License

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.

This tutorial applies to both Construct 2 and Construct 3. Any differences between the two will be noted.

Universal Windows Platform (UWP) apps are Microsoft's new technology to run apps across Microsoft platforms like Windows 10 and Xbox One. Now you can also use Xbox Live in Construct games! This is a requirement for Xbox One publishing as well. You can access Xbox Live features in Construct using the built-in Xbox Live plugin.

Ideally you will already be familiar with exporting UWP apps. There is also a separate Xbox One (UWP) export option, but the exporting process works the same. This tutorial only covers the extra steps to integrate Xbox Live.

Initial registration

Before you get started, you'll need to sign up for the appropriate Xbox Live program. There are two options:

  1. Xbox Live Creators Program
  2. ID@Xbox

The Xbox Live Creators Program is open to everyone and has fewer requirements. However if you are serious about getting a game published to Xbox One, you can apply for the full IDasv@Xbox service, which has access to more features and services but also requires full certification.

Both will require a Microsoft account and access to the Microsoft Dev Center dashboard where you can create and configure UWP apps.

Setting up an app

Before you get started, you'll need to create a new app on the Dashboard. If you've created a UWP app before, you should already be familiar with this. All you need to do is click the "Create a new app" button and follow the steps.

Once you have created an app, you'll need to enable the Xbox Live service. Once you have selected your app, choose the Services drop-down menu and select Xbox Live. The first time you do this you may be prompted to enable the service; follow the steps it provides to enable it.

Once enabled, you should see details about configuring and testing your app with Xbox Live. Take a note of the Title ID, SCID and Sandbox ID details that are listed.

Setting up sandbox and test accounts

Before you can test your app, you will need to set up two more things:

  1. The testing sandbox. This is an isolated environment for testing before you publish an app.
  2. A test account to use in the sandbox.

Microsoft provide their own documentation about this in the Xbox Live documentation. Follow the guide there to get this set up. In short you'll need to switch your Windows 10 PC - or Xbox One in developer mode - to the sandbox previously listed in the app's details. You'll need to use some tools that Microsoft provide to do this. Then use the Dashboard to create a test account which has access to that sandbox. When you later come to test your app, log in with the test account instead of a real account. (Your real account may also work in the Creators Program, but it's probably sensible to isolate everything to a test account anyway so it doesn't affect your real account.)

After you make any changes on the Dashboard, be sure to click the Test button to publish those changes to the testing sandbox. Remember to do this again if you make any more changes later on!

Setting up Construct's Xbox Live plugin

Add the Xbox Live plugin to your Construct project if you haven't already. Note this tutorial is aimed at Construct 2 r245+, and Construct 3 r41+, so make sure you're using the right versions.

When you add the plugin or select it in the Project Bar, you'll see Xbox Live related properties in the Properties Bar. These need to be filled out with:

  • Title ID from the app's Title ID in the dashboard
  • SCID from the app's SCID in the dashboard
  • Xbox Live Creators Title needs to be enabled if you are using the Xbox Live Creators Program; otherwise disable it.

This information allows Construct to configure the exported project correctly.

Using Xbox Live features

To test Xbox Live is working, you'll want to add some events using the Xbox Live plugin. A simple way to start is add a button that does Sign in when clicked, and then use the On sign in success and On sign in error triggers to check the result.

You can also try Sign in silently at the start of the layout. If the user has signed in before and their sign in was remembered, this allows them to be automatically signed in again without being prompted.

Once signed in, the Request profile info action allows you to obtain information about the signed in user, such as their gamertag.

You can read more about other Xbox Live features in the Xbox Live plugin manual entry.

Handling back button

By default the Xbox system treats the B button on the gamepad as a "go back" command, which can exit the app. This can be awkward if your game needs to use this button as input.

To avoid the B button going back, add the Browser plugin to your project and add an empty event with the On back button pressed trigger. This event does not need any actions; if Construct sees an event for the trigger, it will block the default behavior of that action, which will stop the B button going back.

Exporting

When exporting your project, export like a normal UWP app. That means choosing the Windows Store option in Construct 2, and make sure the target version is Windows 10 Universal. In Construct 3 the export option is named Windows & Xbox One (UWP), which exports the same kind of UWP app.

In Construct 2, the exported Visual Studio solution by default uses the Windows 10 SDK version 10.0.10240.0. If you run your project and see an error, you may need to adjust the project settings to change the target SDK version to one you have installed. In Construct 3 you will be prompted for the Windows 10 SDK version you have installed, so it can set this for you.

Currently Visual Studio 2015 and 2017 are supported - older versions of Visual Studio won't work.

Setting up Visual Studio

Once you have exported from Construct, you'll have a Visual Studio solution that you can open. Once you open it in Visual Studio you'll need to make a couple more changes for Xbox Live support to work.

First of all you need to install the Xbox Live package. Do this by right-clicking the project item in the Solution Explorer (which has the name of your project) and choosing Manage NuGet Packages.... Switch to the 'Browse' tab and search for Xbox Live. Select the package named:

Microsoft.Xbox.Live.SDK.WinRT.UWP

This is the one that supports JavaScript in UWP apps. Install this package to your project. It may take a while as it downloads and installs the package.

Next, you need to associate the Visual Studio project with your app you created earlier on the Dashboard. To do this, right-click the project again and this time select StoreAssociate App with the Store.... Follow the steps to link to the app from the Dashboard. You may need to sign in to your account to make sure it can list the apps you've created.

Finally, the Any CPU mode isn't supported for UWP apps using Xbox Live. So next to the green Run button, click the dropdown that says Any CPU and switch it to x64.

Test Xbox Live works

Now hit the green "Run" button (or press F5). Your game should start up. If Xbox Live is configured correctly, the Xbox Live plugin's Xbox Live is available condition should be true. Then if you click the sign in button in your game, a login prompt should appear. Remember to use the test account you created earlier, not your own account. You may need to choose a 'Switch account' option in the login dialog.

If you can sign in with the test account, everything has been set up correctly!

Test on Xbox One

To test on an actual Xbox One console, you need to activate Developer Mode and connect the console to the same local network as your PC. For more information, refer to Microsoft's documentation:

  • 5 Comments

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