Sign in to follow this  

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: = 1.77; = Phaser.ScaleManager.SHOW_ALL;, 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?

Share this post

Link to post
Share on other sites

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., 'assets/sprite.png');
this.someSprite =, 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?

Share this post

Link to post
Share on other sites

I figured out why my sprites where scaled wrong. I did this: = 1920; = 1080;

Instead of this: = 1920; = 1080;

Now everything works as expected.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.