Skip to main content
Inspiring
November 29, 2010
Answered

How to push an object on mouse over?

  • November 29, 2010
  • 1 reply
  • 368 views

What is the best method for tracking the angle of the mouse as it moves over an object so I can push the object in the same direction the mouse is moving with a tween?

Thank you!

This topic has been closed for replies.
Correct answer kglad

use Math.atan2():

var angle:Number=180*Math.atan2(mouseY-object.y,mouseX-object.x)/Math.PI;

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 29, 2010

use Math.atan2():

var angle:Number=180*Math.atan2(mouseY-object.y,mouseX-object.x)/Math.PI;