I’m trying to implement portrait and landscape mode for my game.
At boot state I have:
this.scale.scaleMode = Phaser.ScaleManager.RESIZE;
this.scale.pageAlignHorizontally = true;
this.scale.pageAlignVertically = true;
In index.html I have:
$(window).on("orientationchange", function (event) {
resizeGame();
});
function resizeGame() {
var height = $(window).height();
var width = $(window).width();
TopDownGame.game.width = width;
TopDownGame.game.height = height;
TopDownGame.game.stage.getBounds.width = width;
TopDownGame.game.stage.getBounds.height = height;
if (TopDownGame.game.renderType === Phaser.WEBGL) {
TopDownGame.game.renderer.resize(width, height);
}
}
I init game this way:
TopDownGame.game = new Phaser.Game($(window).width(), $(window).height(), Phaser.AUTO, 'canvasContainer', null, false, true);
When I turn phone from portrait mode to landscape, there is black blackground at the right. As it is seen in second image yellow goal sprite is on top of black background. It seems that tilemap didn’t refresh. Why this is happening?