Jump to content

Angle to mouse click


bangoo
 Share

Recommended Posts

Hi, it should work... this is source for angleToPointer - nothing more than call to atan2:

    angleToPointer: function (displayObject, pointer) {        pointer = pointer || this.game.input.activePointer;        var dx = pointer.worldX - displayObject.x;        var dy = pointer.worldY - displayObject.y;        return Math.atan2(dy, dx);    }

 Important thing is it returns result in radians not in degrees. Relation between degrees and radians is, that whole circle 360 (degrees) = 2 * PI (radians). So, to convert result into degrees do this: degrees = (result / (2 * PI)) * 360 = (result * 180) / PI.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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