2D Toolkit Forum

2D Toolkit => Support => Topic started by: Intrawebs on January 28, 2013, 08:35:10 am

Title: Convert desired runtime width to scale
Post by: Intrawebs on January 28, 2013, 08:35:10 am
I have a header graphic with rounded corners on either side and text in the middle.  The graphic also has a background behind the text.  The size of the text is dynamic.  So thats 4 sprites (left, center, right, text).  I already have code running that sets up the positioning of all of these and I know exactly how long I need the middle background graphic to be.  That graphic is a tiling graphic, so I need to scale it on the x to fit the width of the text.  Is there a way to do this, a way to convert the known and desired width of the graphic and have it scale?

You can see what Im trying to do here
http://i.imgur.com/9Yi9MM2.png (http://i.imgur.com/9Yi9MM2.png)
Title: Re: Convert desired runtime width to scale
Post by: unikronsoftware on January 28, 2013, 10:00:40 am
If it is a tiling graphic, surely you'll need to duplicate + clip the last one to get it to fit, rather than scaling?


If you wanna scale, you can work it out by
xscale = xdistance / bounds.width;
Title: Re: Convert desired runtime width to scale
Post by: Intrawebs on January 28, 2013, 04:28:33 pm
DOH!  Of course I can duplicate it, dont know why I didn't think of that.  I'll also try the other suggestion.  Thanks.