Jump to content

Fixed aspect ration is not respected.


Recommended Posts


I want my game to be always in 16:9 with letterboxing when neccessary. I'm using this code in the very first state:

this.game.scale.aspectRatio = 1.77;
this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
this.game.scale.align(true, true);

When I now start the game after I resized the browser to a quadratic format the aspect ratio is different, close to 1. As if the aspect ratio I set is just being ignored and the canvas is scaled to the complete window.

I'm not in the browser full screen mode. When I start in a format close to 16:9 everything works as expected, thus I guess only at startup something goes wrong.

Am I missing something?

Link to comment
Share on other sites

  • 2 weeks later...

Thank you very much. That worked.

When I now add sprites, they are scaled wrong though. Although I don't touch the scale of the sprite.

this.game.load.image(Assets.SOME_KEY, 'assets/sprite.png');
this.someSprite = this.game.add.sprite(0, 0, Assets.SOME_KEY);
this.someSprite.anchor.set(0.5, 0.5);

The aspect ratio of the sprite is only correct when the canvas has the exact dimensions 1920x1080. Otherwise it is deformed either in width or in height, depending on the size of the screen (browser window). The canvas now always has an aspect ratio of 16:9 as wished. Is there more I have to take into consideration?

Link to comment
Share on other sites


  • Recently Browsing   0 members

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