koobazaur Posted June 14, 2017 Share Posted June 14, 2017 Hello folks, I'm using NWJS to make a standalone build and wanted to make the window re sizable. My game is designed for 1280x720 so ideally I'd like it to scale without needing to re-code everything. Right now I set "game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;" and it scales OnLY with the width. So when I shrink the height, it doesn't scale at all hidden. Likewise, it is capped at canvas size and will not scale above 1280x720px. I'm wondering what the best way to go about doing it, some sort of CSS and Phaser setting mix? Or do I need custom JS to resize canvas based on window size and desired aspect ratio? Does Phaser have any built in functionality to handle that? EDIT: I did googling but all the topics / tutorials are from like 3 years ago, using outdated version of phaser. Link to comment Share on other sites More sharing options...
koobazaur Posted June 14, 2017 Author Share Posted June 14, 2017 EDIT: OK, I think I finally got it working using: window.onresize = function(event) { var gui = require('nw.gui'); var win = gui.Window.get(); console.log("Resizing Window to : " + win.width + "x" + win.height); sGame.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; var d = document.getElementById("gameDiv"); d.style.width = (win.width) + "px"; d.style.height = (win.height) + "px"; sGame.scale.pageAlignHorizontally = true; sGame.scale.pageAlignVertically = true; }; Wonder if there is a better way? Link to comment Share on other sites More sharing options...
samme Posted June 14, 2017 Share Posted June 14, 2017 4 hours ago, koobazaur said: Right now I set "game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;" and it scales OnLY with the width. So when I shrink the height, it doesn't scale at all hidden. Either set game.scale.parentIsWindow = true; or give the container a height: #gameDiv { height: 100vh; } Link to comment Share on other sites More sharing options...
Recommended Posts