Running Booty5 games with node-webkit

What is node-webkit?

node-webkit (also known as NW.js) is an app runtime based on chromium and node.js that enables you to create desktop apps written in HTML, CSS and JavaScript and deploy as a native app. For game developers, that means you can deploy your HTML5 games to desktop quite easily.

You can download node-webkit from Github, run-times are available for Windows, Mac and Linux.

Testing with Booty5

After running test / run from the Booty5 editor you can enter the projects html sub-folder and view the HTML, CSS and JavaScript that was generated for your project. You will need to create a file in this sub folder called package.json which contains the following:

1

2

3

4

5

{

"name":"project_name",

"version":"1.0",

"main":"index.html"

}

To run your exported Booty5 game under NW.js:
* Run a command prompt and change to your games export html folder, for example if your project is located in c:\booty5\games\my_game:

1

cdc:\booty5\games\my_game\html

* From the command prompt run path_to_nwjs/nw.exe . (note the dot), for example if you have nsjs inmstalled to c:\nwjs:

1

c:\nwjs\nw.

Note that when you run your game under node-webkit you will notice that it is ran in a browser window, giving you access to the JavaScript console etc.. for debugging. However you can modify this behaviour to give you the full client area to play with by adjusting your package.json, e.g.:

1

2

3

4

5

6

7

8

9

{

"name":"project_name",

"version":"1.0",

"main":"index.html",

"window":{

"toolbar":false,

"fullscreen":true

}

}

This turns the windows toolbar off and puts the window into full screen.

If instead you want to show a windowed window then you can instead pass a desired with and height of the window, e.g.:

1

2

3

4

5

6

7

8

9

10

{

"name":"project_name",

"version":"1.0",

"main":"index.html",

"window":{

"toolbar":false,

"width":660,

"height":500

}

}

There are various other options that can be passed into the package.json, for a full list see here

For packaging and distributing your node-webkit based native games see here for details.

NOTE: Version 1.9.3b will be the first version of Booty5 that officially works with node-webkit because of the badly named b5.Utils.loadJSON() which doesn’t acknowledge files that have been loaded locally correctly under node-webkit. This only affects sound effects that are loaded and played back via Web Audio, everything else will work.