{
"main": "index.html",
"name": "SpaceBlaster",
"keywords": [ "Construct 2", "node-webkit", "Space Blaster" ],
"version": "0.1",
"keywords": [ "demo", "node-webkit" ],
"window": {
"icon": "logo.png",
"toolbar": false,
"position": "center",
"resizable": true
}
}
Save it as package.json to your node-webkit folder:
aaaaand we're done with notepad++. Great work!
Zipping, renaming
Let's zip our exported app and package.json to a .zip file called app.zip. Rename "app.zip" to "app.nw" using one of two methods:
____________________________
1. By default, file extensions may be hidden. You need to (press alt), go to folder options and uncheck "Hide extensions for known file types" to be able to rename the zip.
If this pops up, click yes:
2. Open CMD and go to your folder("cd path/to/NodeWebkitTutorial/folder") and type "ren app.zip app.nw"
____________________________
Once you renamed it, move app.nw file to app folder.
//Pro-tip if you want to try your exported game right away, just drag //the app.nw file onto nw.exe and enjoy
Command Prompt and finalizing
Open up Command Prompt (Click on start button, then type "cmd", it should show up)
type:
cd path/to/NodeWebkit/folder
cd App
When you are in your App folder, execute the following command:
copy /b nw.exe+app.nw app.exe
It will "merge" app.nw and nw.exe to a new app.exe file
Aaaand congratulations, you just successfully exported a C2 project to .exe using node-webkit!
Wrapping it up
To distribute your app, just delete the nw.exe file, zip the contents of App folder and you're done!
Your final App folder should look like:
Final result
Additional info and sources
- If you export an app with "Fullscreen in browser" set to "off" in construct, exported index.html file will also contain following script:
<script>
// Issue a warning if trying to preview an exported project on disk.
(function(){
// Check for running exported on file protocol
if (window.location.protocol.substr(0, 4) === "file")
{
alert("Exported games won't work until you upload them.");
}
})();
</script>
Delete it. It will remove the annoying pop-up when you start your exe.
-Currently, there are three plugins to access possibilities of node-webkit
Node-webkit GUI plugin
Plugin provides acces to UI elements, clipboard and more
node-webkit node.js OS plugin
Plugin provides a few basic operating-system related utility functions using node.js OS module with node-webkit export.
Node-webkit Node.js PATH plugin
This plugin contains utilities for handling and transforming file paths.
NOTE: plugins are still in development, use them wisely!
- Use 7zip to zip files, you can set file extension regardless of compression method (saves you the file-renaming step)
- You can try to set "nodejs" to false in package.json
nodejs. It will disable node inside WebKit, if you're only using HTML5 to write apps, it could improve stability and performance.
- Forum thread on node-webkit and construct 2 here
That's it, have fun, enjoy and don't forget to drink water or walk around after heavy Construct 2 sessions!