Sign in to follow this  
Choeeey

Simple Question: How to Change size of an image

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 :)

 

 

Share this post


Link to post
Share on other sites

well... the best way would be to fire up "gimp" or any other graphics editing software and reduce the size ... but if you want to do it in phaser you can just write:

myimage = game.add.sprite(0,game.world.height-250, 'cat');myimage.scale.setTo(0.5,0.5);

and it will be half the size

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. :/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.