Sign in to follow this  
catccaatt

Is there a way to scale sprite's x,y,width,height

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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;

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.