Jump to content

Simple Question: How to Change size of an image


Choeeey
 Share

Recommended Posts

Hi Everyone,

 

Completely new to Phaser so I am, embarrassingly, having problems even just scaling an image down.

 

Code looks like this:

 

var game = new Phaser.Game(
    800, 600, Phaser.AUTO, '', 
    { preload: preload, create: create, update: update });
 
 
 
 
function preload(){
game.load.image('cat', 'cat.png');
}
 
function create(){
    
 game.stage.backgroundColor = "#8A2BE2";
    game.add.sprite(0,game.world.height-250, 'cat');
 
}
 
function update(){
    
    
}
 
Could Someone show me how to set the size of the image, cat?
 
At the moment it is far too big.
 
Thanks in advance :)

 

 

Link to comment
Share on other sites

  • 4 weeks later...

valueerror is right.

 

you can also set
 

myimage.width = 40;myimage.height = 25;

This way you can distort images if you do not consider the ratio.

Mostly not the way you want it to, but useful for some exceptions.

Link to comment
Share on other sites

  • 2 years later...

scaleTo works, but I'm using "this.cat.scale.setTo(.05, .05);" which REALLY makes the image pixelated and not good looking. How can I have nice, crip graphics but still kep them small? I'm using texturepacker, but I don't think I can change the size of the images in there... Do I need to shrink the images in spriter and/or illustrator? I bought this spritesheet, but I'm having trouble adding it into my game and having it look good. :/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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