Jump to content

Reposition a sprite relative to its parent's rotation


d13
 Share

Recommended Posts

post-5513-0-36614700-1405387533.png

 

I need to keep a child sprite's position and rotation aligned to its parent.

So if the parent rotates, the child should maintain the correct position and rotation.

 

Does anyone know what the formula for this is?

 

Thanks!

Link to comment
Share on other sites

I got an answer to this on Stackoverflow:

 

http://stackoverflow.com/questions/24748667/reposition-a-sprite-relative-to-its-parents-position

 

It turned out to be really simple, I was just overthinking it.

All you do is draw the parent's children between the same save() and restore() canvas call.

As long as you have both local and global x/y co-ordinates to help with the positioning, it's very easy to implement.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...