catccaatt Posted January 14, 2015 Share Posted January 14, 2015 Hi, I looked around but haven't found anything. Is there a way to scale a sprite's x,y,width,height by specifying some parameter? The idea is: if I developed some thing on screen 100x50 and let a sprite be x,y,width,height=50,25,10,5,when the really device scaled 10 times larger 1000x500, I want the sprite to be 10 times larger to be looking right and position to be 10x10, 5x10 If there is not, is the best way to extend a sprite? Thanks Link to comment Share on other sites More sharing options...
MichaelD Posted January 14, 2015 Share Posted January 14, 2015 try sprite.scale.setTo(10, 10);(sprite is any variable containing a sprite) Initial scale of all sprites is 1 for the x, y you could dosprite.x = sprite.x * sprite.scale.x;sprite.y = sprite.y * sprite.scale.y; Link to comment Share on other sites More sharing options...
ultimatematchthree Posted January 15, 2015 Share Posted January 15, 2015 This isn't a direct answer to your question, but based on the way you've described your issue, it seems like what you're actually trying to do is scale your game based on the device's screen size. Here's a recent discussion about that, and you'll probably want to look into the Phaser Scale Manager's RESIZE mode as well. Rich has written an entire book on the Phaser Scale Manager, hopefully it will be helpful to you. Link to comment Share on other sites More sharing options...
catccaatt Posted January 16, 2015 Author Share Posted January 16, 2015 I briefly look at scale manage. It doesn't look like a per sprite based mechanism. If it is not, then it won't satisfy my need as I want some sprite to be always in the corner ( like the arrow key ), and some sprite always be in the middle ( like the title sprite) no matter how the screen is scaling. I need a way to specify which sprite is align by corner or by middle so the scaling will not mess up the alignment. Link to comment Share on other sites More sharing options...
MichaelD Posted January 16, 2015 Share Posted January 16, 2015 If you declare the position like this:sprite.x = 0;//orsprite.x = (game.width/2) - (sprite.width/2);The scaling will not mess with alignment. for the corner you can do:// top leftsprite.x = 0;sprite.y = 0;//top rightsprite.x = game.width - sprite.width;sprite.y = 0;//bottom rightsprite.x = game.width - sprite.width;sprite.y = game.height - sprite.height;//bottom leftsprite.x = 0;sprite.y = game.height - sprite.height; Link to comment Share on other sites More sharing options...
Recommended Posts