visgotti Posted October 16, 2020 Share Posted October 16, 2020 https://jsfiddle.net/2hb18pzg/1/ In that fiddle I want the green rectangle sprite to always be in the top right corner of the parent as they rotate. I know I can solve this by using a parent container but I want to do this without a container, I know it's something to do with setting the child's anchor and pivot correctly relative to the parent, but I can not for the life of me figure out how to do it properly. Quote Link to comment Share on other sites More sharing options...
wes101620 Posted October 17, 2020 Share Posted October 17, 2020 Maybe this is a solution you're looking for. Updating child x coordinate to match the parent in your loop. setInterval(() => { parentRect.rotation += .5; childRect.rotation += .5; childRect.x = parentRect.x; renderer.render(mainStage); }, 100) Quote Link to comment Share on other sites More sharing options...
jonforum Posted October 17, 2020 Share Posted October 17, 2020 Am sure you will not keep your variable hard coded like this , but basic math operations from rotations should do the jobs ! childRect.rotation = -newRotation/newRotation-0.5; for this demo is work, in a complexe case you will need make more solide math algo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.