Jump to content

Is there ScaleManager in Phaser 3


KungFuFlames
 Share

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;
}

Link to comment
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.

this.events.on('resize', resize, this);


function resize (width, height)
{
    if (width === undefined) { width = this.sys.game.config.width; }
    if (height === undefined) { height = this.sys.game.config.height; }

    this.cameras.resize(width, height);

    this.bg.setSize(width, 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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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