Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Child's world translation/rotation — Gideros Forum

Child's world translation/rotation

Bill5567Bill5567 Member
edited December 2012 in General questions
If you attached child sprites to a parent, then move and rotate those children, then move and rotate the parent.
How do you get a child worlds position and rotation ?

e.g. if you built a character out out various body parts. You can attach the upper arm to the shoulder, the lower arm to upper arm, the hand to lower arm. If you rotate the upper arm, the lower arm and hand also rotate.

But if you get the rotation and position of the hand, it will be local to it parent.

How to you get the world position and rotation ?

Exactly this is done to traverse the scene graph to render the images. I know its todo with the matrix's. I've tried multiplying them altogether, but some things not right.

I need to get the hands world position and rotation. Thanks.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    Sprite has a Sprite:localToGlobal(x, y) method, which converts local Sprites coordinates to the global coordinate system.

    Additionally you could use Sprite:getBounds(targetSprite) and provide the target sprite, for example stage, to which coordinates it should be translated.

    But I don't know anything for rotation, so most probably you'll have to traverse and sum up all parent rotations till the element relative to which you need it ;)
  • Thanks, I didnt see the Sprite:localToGlobal api.
Sign In or Register to comment.