Game Development Community

Getting the world position of a sprite within a CompositeSprite

by Eric Armstrong · in Torque 2D Professional · 09/16/2013 (3:56 pm) · 2 replies

I have a CompositeSprite that is responsible for rendering the monsters in a maze. I can select and move the sprites without an issue, but I was wondering if there was a way to get the world position for a specific sprite within the CompositeSprite. There is a method to get the local position of the selected sprite, but I didn't see a way to get the world position. If it is a matter of doing the math to convert from local to world, I'm fine with implementing that if someone explains the basic steps.

The end result of what I'm attempting is to do a pickArea on the scene based on the position of the sprite. If there is another way to do that, I'm open to suggestions for that too.

Thanks.
Eric

#1
09/17/2013 (10:40 am)
I did a quick test and the numbers the console was spitting out looked ok:

%local = MyCompositeSprite.getSpriteLocalPosition();
%world = MyCompositeSprite.getWorldPoint(%local);

getWorldPoint is a SceneObject method.
#2
09/17/2013 (10:58 am)
Works perfect! Thanks Mike. I knew there had to be a call in there someplace to figure that out.

Eric