Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Game scaling - force width to fill viewport - keep aspect ratio and height


ptotheaul
 Share

Recommended Posts

I have a game that on mobile devices I want to scale the game to 100% of the window width and keeping the aspect ratio have the height scale up and go off screen at the bottom if the aspect ratio make the height taller then the view area.  Is this possible just using the Scale Manager?

Link to comment
Share on other sites

I've found this code that does what Phaser.ScaleManager.SHOW_ALL if I put it in the call back of USER_SCALE but know I need help figuring out how to limit the user scaling to the horizontal:

 

gameResized(manager, bounds)
  {
      var scale = Math.min(window.innerWidth / this.game.width, window.innerHeight / this.game.height);

      //canvas.width = (game.width * hScale) - hTrim
      //canvas.height = (game.height * vScale) - vTrim

   
      manager.setUserScale(scale, scale, 0, 0);
  }

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...