Sign in to follow this  

Is there ScaleManager in Phaser 3

Recommended Posts

If you want to SHOW_ALL, you can use .css to implement it

html, body {
        height: 100%;
body {
    margin: 0;
    padding: 0;
    background: white;
canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;

Share this post

Link to post
Share on other sites

That's an alternative too. But I don't think CSS should handle entiry scaling of the game. For example your code won't make canvas to 'fit' into page body. Which is not a problem but most of the mobile games probably will try to cover the fullscreen of the divice. Although, this is easy to fix just by adding couple lines into CSS, from my experience so far I found that Sprites are losing quality with CSS methods. So JS is fine right now, but not really sure if this is good performance wise.'resize', resize, this);

function resize (width, height)
    if (width === undefined) { width =; }
    if (height === undefined) { height =; }

    this.cameras.resize(width, height);, height);
    this.logo.setPosition(width / 2, height / 2);

Basicly the event will trigger on resize, then going to calculate 'things' based on new canvas size and will setup new size and position(or whatever) for Spirte.

This whole process doesn't look very efficient for me.

If you have any ideas how I can optimize it, I will be glad to hear your suggestions.

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.