Choeeey Posted October 16, 2014 Share Posted October 16, 2014 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 More sharing options...
valueerror Posted October 16, 2014 Share Posted October 16, 2014 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 Choeeey 1 Link to comment Share on other sites More sharing options...
Choeeey Posted November 11, 2014 Author Share Posted November 11, 2014 Thank you Link to comment Share on other sites More sharing options...
Sam Posted November 12, 2014 Share Posted November 12, 2014 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 More sharing options...
Jimaginary Posted April 20, 2017 Share Posted April 20, 2017 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 More sharing options...
Recommended Posts