Running Construct 2 on Linux

1

Stats

1,661 visits, 2,272 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.

Published on 27 Aug, 2023.

If you are user of Linux, you probably tried to run Construct 2, but when you tried to preview project, the error ocurred. I have a fix for that.

Downloading Wine

The first step is to download Wine. Instructions for installation are listed here.

After you installed Wine, run command winecfg as non-root user in terminal. When you asked to install something, install it, because otherwise you can be left with uninstalled libraries. When window with Wine's configuration appears, close it, do not edit settings. Now we finally installed Wine.

Note that after its installation, there is .wine folder in your home directory (If you can't see it in file explorer, press ctrl+H to make hidden directories visible). This folder is the home folder where Wine stores all files (your apps etc.) and inside it you can find directory called drive_c, which emulates Windows' file system.

Installing Construct 2

Now, we need to install Construct 2 on Wine. Head to Construct 2 installation page and download exe file. When it has downloaded, rename it to construct.exe. Now, open terminal (as non-root user), type cd `Construct installer location` and wine construct.exe. This should launch Construct 2's installer. Do not touch any parameters, just click Next button until installation process is finished. You've successfully installed Construct 2!

Launching Construct 2 for the first time

Now you probably want to test it out! To do so, open terminal and type cd '.wine/drive_c/Program Files/Construct 2' and then type wine Construct2.exe. When it asks to install something (Gecko, for example), do it by pressing 'Install' button. After sometime, Construct 2 should open. If you've made it so far, congrats!

But there's one problem, preview doesn't work. By that I mean that Wine is not yet capable of using API for starting Web server that Construct 2 uses, so you'll not be able to preview your project through official preview feature. But there's workaround :)

Fixing the preview

To preview the project, we'll need to use other method. This method involves Apache, blank exe file and python script.

Installing Apache2

We'll need to use our custom Web Server for preview. I'll use Apache2, but if you're expert you can use other Web servers as well. To install Apache, simply type in terminal sudo apt install apache2 (as root), and then we need to configure it.

Configuring Apache2

We need to specify a folder for our web server, so create a new folder in your home directory (with name, for example, web), and then open a terminal as root user. Run the command sudo nano /etc/apache2/sites-enabled/000-default.conf and change /var/www/html to /home/YourUsernameHere/web. Then, press ctrl+O, then hit Enter and finally ctrl+X. Finally, you need to reload apache. To do so, run command sudo service apache2 restart. Congratulations, you've configured Apache2!

Python script

Now, we need actual fix for preview. I wrote a python script which will upload files from Construct 2 to our Web Server.

First, install Python. There are tons of tutorials online, so it shouldn't be a problem :)

Then, you need to download my python script, which will actually fix the preview. After you downloaded the archive, extract it, and open config.json file. There, you should specify two fields.

"web" Field

In this field you should write path to your Web server (/home/YourUsernameHere/web/). Your path should contain slash / in the end and you should write path inside quotation marks.

"temp" Field

This field needs to contain path to Temp folder where Construct 2 stores all files from previews. This folder is usually located at /home/YourUsernameHere/.wine/drive_c/users/YourUsernameHere/Temp/. Write it inside quotation marks, and like the "web" field, it should contain slash / at the end.

Launching script

Now, after preparations are complete, it's time to launch our script! But first, we need to launch Construct 2, open a project (it can be whatever project you choose) and then click 'Run layout' button. It may open your default browser, but that doesn't matter. Launch the script using command python main.py (or python3 main.py) and then hit Enter. If you didn't encounter any errors, open browser and type localhost/preview.html in URL field. If your game started and it's playable, it's great! You did everything right. But we need to get rid of annoying browser that opens whenever you click 'Preview' button in Construct 2. And that brings us to the Blank EXE file.

Blank EXE

In Construct 2 there's option with custom browser, which allows us to preview game in different browsers that aren't listed in the default list. We can use it and specify custom browser's path to EXE file that does nothing, so there won't be any opening windows, just Construct 2 sharing us some files :)

Download blank EXE file here. Unpack archive, and copy file DoNothing.exe. Put it in .wine/drive_c/Program Files/Construct 2 folder, then launch Construct 2, head to Preferences, Preview and set custom browser's path to DoNothing.exe file and choose option 'Custom' in Preview browser field. Now, press 'Run Layout' and there's no any annoying windows :). Then, you can hit Enter in Python script again to refresh files, and you're good to go :)

Everytime you press 'Run Layout' in Construct 2, refresh files by hitting Enter in Python script, go to localhost/preview.html URL in your browser, and there you can play your game.

Thank you for reading my first tutorial! If you have any problems, please write about them in comments, I'll try to fix them as fast as I can!

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Howdy there! Thank you for taking the time to get Construct 2 to work on Linux!

    Sadly I can't get it to work, I'm getting an error when I enter localhost/preview.html:

    "Uncaught InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state. localhost/preview.js, line 1910 (col 11)"

    Any idea what it may be causing it?