davestephans

Members
  • Content count

    1
  • Joined

  • Last visited

  1. Hi, I am facing one problem with game resizing, here i resized the whole canvas width and height based on the device browser width and height. maximum width and hieght is 1920x1080. The problem is when i called the game.scale.setUserScale(scaleFactor,scaleFactor), after that the canvas width and height did not change. Here the canvas width and height will be change when mobile device get rotation like portrait to landscape and landscape to portrait. What will be the problem, could you guys any one help me. My code is, var windowWidth = window.innerWidth; var windowHeight = window.innerHeight; var GAME_MAX_WIDTH = 1920; var GAME_MAX_HEIGHT=1080; var scaleFactor=1; if((GAME_MAX_WIDTH/windowWidth) > (GAME_MAX_HEIGHT/windowHeight)) { scaleFactor = (windowWidth / GAME_MAX_WIDTH); } else { scaleFactor = (windowHeight / GAME_MAX_HEIGHT); } var positionX = windowWidth/2 - (GAME_MAX_WIDTH*scaleFactor)/2; var positionY = windowHeight/2 - (GAME_MAX_HEIGHT*scaleFactor)/2; var view = document.getElementById('game_div_id'); view.style.top = positionY+"px"; view.style.left = positionX+"px"; mainGame.scale.scaleMode = Phaser.ScaleManager.USER_SCALE; mainGame.scale.setUserScale(scaleFactor,scaleFactor); Thanks,