Zendrael Posted November 14, 2015 Share Posted November 14, 2015 Hi! I have built a resize function that scales my CANVAS accordinly to the space available, it shows more or less objects in the scene depending on the horizontal value and scale the canvas to it. It works but right after it is called, the canvas gets back to its default size!!!! VERY ANOYING! The code:function resizeGame() { var actualWidth = window.innerWidth; var actualHeight = window.innerHeight; GAME.scale.setGameSize( Math.ceil((actualWidth * 160) / actualHeight), 160); var widthToHeight = GAME.width / GAME.height; //4 / 3; var newWidth = window.innerWidth; var newHeight = window.innerHeight; var newWidthToHeight = newWidth / newHeight; if (newWidthToHeight > widthToHeight) { newWidth = newHeight * widthToHeight; GAME.renderer.view.style.height = newHeight + 'px'; GAME.renderer.view.style.width = newWidth + 'px'; } else { newHeight = newWidth / widthToHeight; GAME.renderer.view.style.width = newWidth + 'px'; GAME.renderer.view.style.height = newHeight + 'px'; } //atribui o tamanho final GAME.renderer.view.style.width = newWidth;}So, my question is: why my game gets back to teh original size (240x160) righr after the page loads???How to set the style permanent??? Thanks! I'm new to phaser... Link to comment Share on other sites More sharing options...
Recommended Posts