Skip to main content
March 11, 2012
Answered

Orientation relations between 2 objects on stage

  • March 11, 2012
  • 1 reply
  • 414 views

I have 2 simple objects on stage: 1 is a static circle with a sharp tip (to show direction of the object) and 1 moving circle (moves according to users mouse or just a constant random move).

I want the static circle orientation to change according to moving circle position (so the sharp tip will always point at the moving circle).

What I did is divide the stage to 8 sections, each is linked to a specific orientation of the static circle.

It works, however it is very rough and I need it a lot more smooth.

I am sure there is a better way to do this, I just can't find it...

Any suggestions will be welcomed.

This topic has been closed for replies.
Correct answer Ned Murphy

You can do it programmatically using the atan2 method. You can probably find a tutorial if you search Google using search terms like "AS3 atan2 tutorial" or "Flash follow mouse atan2"

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 11, 2012

You can do it programmatically using the atan2 method. You can probably find a tutorial if you search Google using search terms like "AS3 atan2 tutorial" or "Flash follow mouse atan2"