Created
January 6, 2015 00:33
-
-
Save leigh-johnson/511be9d4a3c54717da2f to your computer and use it in GitHub Desktop.
OnEvent resize + handler to dynamically resize WebGL & Canvas element in Phaser.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add to game init | |
$(window).resize(function() { window.resizeGame(); } ); | |
//add this function to main.js | |
function resizeGame() { | |
var height = $(window).height(); | |
var width = $(window).width(); | |
game.width = width; | |
game.height = height; | |
game.stage.bounds.width = width; | |
game.stage.bounds.height = height; | |
if (game.renderType === Phaser.WEBGL) | |
{ | |
game.renderer.resize(width, height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment