Game Development Community

Align images through Script

by Tom Lenz · in Torque Game Builder · 10/08/2009 (3:45 pm) · 3 replies

Been looking for a while, but haven't come across anything yet.

What I'm looking for is a way to align multiple sprites along the edge of their bounding box. Something similar to what you can do in Word by aligning right or left.

The images are different sizes so I need a way to make sure the very left edge of the images are lined up.

Thanks in advanced.

#1
10/08/2009 (4:19 pm)
I assume you created the sprites dynamically and want them aligned to a specific location on the right.

In that case, you get call getWidth() on the sprite, take half of it, and then subtract it from the X-coordinate you want to right-align with.
#2
10/08/2009 (5:56 pm)
Thank you much,

Maybe instead of posting a thread I should just send you an email. ;) You seem to have all the answers.
#3
10/08/2009 (7:58 pm)
You're welcome!

I'm the sweet, chocolate, answer man! (Okay, that was really bad, but it popped into my head.)