Resize sprites during runtime to fit screen

Hello!

I’m looking for an efficient way to resize sprites to fit the size of the screen. I would like everything to be scaled proportionally to the screen size. All tips are appreciated!

Thanks!

Easiest is scale mode FIT.

Hi!

Appreciate it!

this is my current scale configuration:

  scale: {
    mode: Phaser.Scale.ScaleModes.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    width: window.innerWidth,
    height: window.innerHeight,
  },

With this the sprites seem to keep the same size what ever screen size it is. My goal is to make the sprites adapte so they are not too small or too big for the screen.

Use constants for width and height.

Thanks for the tip!

This time I need the screen to be more responsive that Phaser.Scale.ScaleModes.FIT.
I guess I need to do some calculation of sizes depening on the screen size.

The other way is to use mode RESIZE and zoom cameras to fit.

will try that, thanks a bunch!