Question about Rotation

Hey guys, i have a dobut, can you make an object rotate around another object? (set the anchor x and y on the other object x and y?

I’m making a guy hold a lantern (top view), i can make the guy rotate and move perfectly but if i rotate the lantern it will rotate on its own reference point (center of the .png), i know how to change the reference point on the object itself (setReferencePoint( display.TopLeftReferencePoint) for example) but im not sure if u can set it to another object x,y.

I could put some screenshots here for u to see what im trying to do if u dont understand it, but i cant post any code with my WIP since i have no idea how to make it rotate like that, however i will submit any piece of code u want of the working stuff.

Thanks in advance and excuse my english (spanish speaker here :P)

Again, if u dont understand what im trying to do just ask me i will try to explain myself a bit better.

Edit: typo

Edit: apparently the setReferencePoint is deprecated and need to use the anchors, it wont fix the problem anyways :/, i cant put the guy and the lantern on the same .png since the lantern has alpha on it and the guy is solid.

If you’re using physics, there may be a joint type that would work.   There are two other non-physics ways I can think of to do this.  The first is to go the math route and plot the X, Y of your rotating object around some center point. I don’t have that math in my head, but a google search should come back with the math for you.

The other way is to do a trick with groups and anchor points.  You can put your object you want to rotate into a group, move the group to the point that you want to rotate around and then simply change the angle of the group.  You can use a transition.to to do the work then.

Rob

Thanks for your reply Rob, i actually went the really easy and 0 knowledge path, merged the 2 .png giving some alpha to the lantern on the .png itself and well, that worked, i wish i knew a bit more to find any of the solutions u had :frowning:

I’m actually stuck in another piece of code right now, trying to find the way around. Something with points inside trinagles.

And no, im not into physics yet, but i saw some samples and it seems pretty good :slight_smile: might check it soon.

If you’re using physics, there may be a joint type that would work.   There are two other non-physics ways I can think of to do this.  The first is to go the math route and plot the X, Y of your rotating object around some center point. I don’t have that math in my head, but a google search should come back with the math for you.

The other way is to do a trick with groups and anchor points.  You can put your object you want to rotate into a group, move the group to the point that you want to rotate around and then simply change the angle of the group.  You can use a transition.to to do the work then.

Rob

Thanks for your reply Rob, i actually went the really easy and 0 knowledge path, merged the 2 .png giving some alpha to the lantern on the .png itself and well, that worked, i wish i knew a bit more to find any of the solutions u had :frowning:

I’m actually stuck in another piece of code right now, trying to find the way around. Something with points inside trinagles.

And no, im not into physics yet, but i saw some samples and it seems pretty good :slight_smile: might check it soon.