bangoo Posted July 18, 2015 Share Posted July 18, 2015 How can I find the angle between the sprite and the mouse click. I use this but it doesn't work: var movingAngle = game.physics.arcade.angleToPointer(sprite); Link to comment Share on other sites More sharing options...
Tom Atom Posted July 19, 2015 Share Posted July 19, 2015 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 More sharing options...
Recommended Posts