Custom Features & Debugging Tools
How To: Speed Up The Startup Time Of Your Game
The game takes a long time to start up. The "package.nw" file is very large and contains a lot of assets.
Steps To Add/Fix/Workaround:
- Go to your exported Win32/Win64 folder(s)
- Rename "package.nw" to "package.zip" and unzip it
- Rename the unzipped folder to "package.nw" and remove all the old files
How To: Set Your Own Application Icon
The game is using the default NWjs icon as the app icon.
Steps To Add/Fix/Workaround:
Windows only:
- Convert PNG to ICO using an Online Converter [16-128px; 32bits]
- Start ResHack
- Open the nw.exe file(s)
- Right-click on "Icon Group" and "Replace Icon"
- Select and replace the application icon(s)
- Save and remove any backup/original files if needed
MacOSX only:
- Convert PNG to ICNS using an Online Converter [128px]
- Paste your new icon into *.app/Contents/Resources
How To: Hide/Prevent Chrome Devtools For The End-User
Dev-tools can be accessed by pressing "F12". Users can also access dev-tools in right click menu's or similar.
Steps To Add/Fix/Workaround:
Prevent most ways to access dev-tools:
- Add --disable-devtools to the "chromium-args" properties
Completly remove dev-tools access:
- Install the custom "Normal" build from the NWjs downloads website
How To: Test Your Game On Higher Framerates Than 60FPS
The game runs at a higher framerate than 60fps. The user's monitor runs at more than 60hz. Noticeable bugs for certain behaviors or game mechanics without dt (delta-time) in use.
Steps To Add/Fix/Workaround:
Bugfix for game eventing:
- Add missing delta time multiplications (Tutorial ➚)
Testing on higher framerates:
- Open the "package.json" file(s)
- Add --disable-gpu-vsync --disable-frame-rate-limit to the "chromium-args" properties
Limiting the framerate (might not work with NWjs v0.33.0+):
- Open the "package.json" file(s)
- Add --limit-fps=X to the "chromium-args" properties (e.g. --limit-fps=144)
How To: Use The Built-in NW.js FPS Counter
Too lazy to add a simple FPS counter to the game.
Steps To Add/Fix/Workaround:
- Open the "package.json" file(s)
- Add --show-fps-counter to the "chromium-args" properties
How To: Modify/Remove Right-Click Context Menus
Customized textboxes show a right-click menu, ruining the immersion of the game.
Steps To Add/Fix/Workaround:
Completly remove right-click menus:
- Add the browser plugin to your project
- Select an event which only triggers once (e.g. inside the loader layout)
- Add the browser action execute javascript
- Execute the following code:
"document.addEventListener('contextmenu', function(e){e.preventDefault();}, false);"
Leave "Cut", "Copy", "Paste" in right-click menus:
- Add the browser plugin to your project
- Select an event which only triggers once (e.g. inside the loader layout)
- Add the browser action execute javascript
- Execute the following code:
"var gui=require('nw.gui'),menu=new gui.Menu;menu.append(new gui.MenuItem({label:'Cut',click:function(){document.execCommand('cut')}})),menu.append(new gui.MenuItem({label:'Copy',click:function(){document.execCommand('copy')}})),menu.append(new gui.MenuItem({label:'Paste',click:function(){document.execCommand('paste')}})),document.addEventListener('contextmenu',function(a){a.preventDefault(),(a.target instanceof HTMLInputElement||a.target instanceof HTMLTextAreaElement||a.target.isContentEditable)&&menu.popup(a.x,a.y)});"
(Code provided by Colludium.)
How To: Fetch & Make Use Of Command-line Arguments
The NWjs plugin can't fetch and make use of any command-line arguments.
Steps To Add/Fix/Workaround:
- DOWNLOAD the example project
- Define the command-line argument (use the global variable)
(Example provided by armaldio.)
How To: Force GC To Instantly Unload Audio From Memory
Garbage Collector is not doing the job and bloats memory usage.
Steps To Add/Fix/Workaround:
- Open the "package.json" file(s)
- Add --js-flags=--expose-gc to the "chromium-args" properties
- Execute the following JS code using the browser plugin: