Cocos2d-X Early Xbox One Implementation (Lua)

Greentwip
4 min readJul 12, 2020

--

We’ve been working into porting our video games to consoles during the last few years and today we are pleased to announce that we get the Cocos2d-X game engine working for Xbox One, with the Lua bindings, by the way.

If you have a Lua project working just fine and you’re interested into bringing it to the Xbox One platform this post might be just right for you. Or the case you want to start developing for the Microsoft platforms and want to try a scripting language with an amazing game engine.

Please do note that while the port might work for the C++ version of the game engine it is been untested, JS support is definitely not there. There is also a preempted consideration, the axes are not yet inside our port (Joystick and left-right triggers), we plan adding those in a near future since we’re decided to move towards publishing our game in December.

This solution is compatible with the 3.15 version of Cocos2d-X, although we plan upgrading to version 4 as soon as possible.

Also, you have to consider spending a few bucks (one-time) to develop for Xbox One and UWP if you want to publish for Xbox or the Microsoft Store.

Our video game uses Texture Packer and Physics Editor, so if you haven’t purchased those tools yet it is suggested to do so (or try them for free).

Also be sure to have installed Visual Studio 2019 and Git with LFS support. Visual Studio should have included the C++ installation options with Windows Store Apps support, more info on setting up your UWP environment on Xbox One.

Let’s start!

In order to keep out you from burden we have carefully packed all the engine modifications and the source code of our video game in one single repository. If you ask, it is being named GT-Engine since the very first mock up of the video game was supposed to be an engine on top of the Lua scripts used by Cocos2d-X, but anyhow, you start up by setting up the repositories by feeding the following command to your console:

git clone --recurse-submodules -j8 https://github.com/Greentwip/GT-Engine-Patched GT-Engine

LFS is being replaced, it used to be there because we were hosting our resource files and dependencies. If you used the git lfs clone command please update your copy of the repository with the above command.

Before we move ahead, it is important to keep 2 files, the dependencies for Cocos2d-X (including UWP/Xbox One) and the Resources file.

Dependencies should be extracted into the frameworks/cocos2d-x folder and Resources should go into the frameworks/runtime-src folder.

Dependencies: 
external: https://drive.google.com/file/d/1dfVGV2Rt45231KpsGuWU7GKzSwSVx2dl
Resources: https://drive.google.com/file/d/1IvgYSkQXYWtOkAHjuMamfdxMk_PDbX6D

When all of the above it’s done, check out the runtime-src folder, then head up to proj.win32 and open the solution file. Visual Studio should ask for upgrading the projects, just click ok and we’re into it.

Before trying to debug anything, you should setup the following Debugging fields in the Property Pages:

$(ProjectDir)..\..\..\Simulator\win32\revenge_of_the_future.exe$(ProjectDir)..\..\..\Simulator\win32

This way we ensure the lua source files and resources get copied to the simulator final build folder. Otherwise you will have to copy them manually.

Ensure revenge_of_the_future is set as the startup default project:

And click the Local Windows Debugger button:

If everything went ok you should see this screen:

That means we’re ready to move towards the UWP/Xbox One project.

You should have read the Microsoft article on setting your UWP environment on Xbox, if you already have running a sample app you can straight go to the frameworks/runtime-src/proj.win10 folder and open the revenge_of_the_future.sln solution file.

Next up, select your build configuration:

Then click the Remote Machine button.

You are all set up! It should be running correctly on your Xbox One.

Remember that Xbox One is a 64 bits platform and you should be using that configuration to debug and deploy your application, although, while uploading your application to the Microsoft Store you should remember to replace the default images in the Assets folder with custom of your own and also provide the x86 build for testing purposes.

In the next post we will provide you some sort of introduction towards the development of Nino’s Future, which is called Revenge of the Future internally due to legacy on the project’s development.

--

--