Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

a simple way to load different resolution assets?


Mike018
 Share

Recommended Posts

There seems to already be a few posts about this a few years ago, and after reading them, there seemed to be no simple definitive solution, and a handful of "this kind of works" solutions. I want to keep things as dead simple as possible. I have my game set as 360, 640 using SHOW_ALL. I want to have 2-3 different resolution assets that just loads based on the detected resolution, while maintaining the scale of the object to the world, that's all. Is there an easy way to do this?

Link to comment
Share on other sites

I have a highly experimental version of Phaser laying around at https://github.com/orange-games/phaser-multires You're welcome to try it.

You simply append your image name with @1x (base res) or fi; @0.5x. It will automaticly upscale the @0.5x image to match the @1x resolution.

Basic Image / Sprite, atlasses and pixel perfect hit detection work, but there are some issues regarding Bitmaps.

All you still have to do is do the check of which image to load, but this can be done fairly easy.

 

if (window.innerWidth < 640) {
     //Small image
     game.load('my-image', 'my-image@0.5x.png');
} else {
     //Normal image
     game.load('my-image', 'my-image@1x.png');
}

 

There is a simple example in the repo, but for now I don't have the time nor do I want to give any additional support on this :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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