Jump to content

How to scale image, not sprite


Recommended Posts

I'm making a game for mobile platforms and you know every phone and tablet has different screen area.


Scaling an image is only available for sprite as far as I'm concerned. Is there a way we can scale the image right after loaded, so that all sprites that use this image will use scaled version.


I want to scale it in this point:

this.load.image('logo', 'images/logo.png');
Link to comment
Share on other sites

Did you know you can display a preloaded Image as a sprite?

this.load.image('logo', 'images/logo.png);var logo = this.game.add.sprite(x , y, 'logo');logo.scale.setTo(1 , 1); // here is where you can scale your image. 1 , 1 is original size so you can make it twice as big with 2 , 2 or half the size with 0.5, 0.5
Link to comment
Share on other sites

@jmp909 I have some images that should have fixed size no matter what device. So, extending sprite class wouldn't work for them.

surely you could implement the device/resolution check into your extended constructor, and therefore whenever you create a new sprite it does all the work behind the scenes to set it up correctly

Link to comment
Share on other sites

  • 5 months later...

Downscaling images before they are loaded into the cache would be incredibly useful, not just for dealing with mobile devices. If you are able to downscale images, you don't need to manually resize each of your (potentially) hundreds of assets whenever you want to change the scale of your game. Sure you could rescale the render to the same effect, but that has a huge impact on performance. Scaling the image before it makes it into the cache is the way to go. Unfortunately, I don't see a way to do this in phaser.  

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


  • Recently Browsing   0 members

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