File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1698,4 +1698,21 @@ Phaser.Physics.Arcade.prototype = {
16981698
16991699 }
17001700
1701+ /**
1702+ * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account relative to the world.
1703+ *
1704+ * @method Phaser.Physics.Arcade#worldAngleToPointer
1705+ * @param {any } displayObject - The DisplayObjerct to test from.
1706+ * @param {Phaser.Pointer } [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used.
1707+ * @return {number } The angle in radians between displayObject.x/y to Pointer.x/y
1708+ */
1709+ worldAngleToPointer : function ( displayObject , pointer ) {
1710+ pointer = pointer || game . input . activePointer ;
1711+
1712+ var dx = pointer . worldX - displayObject . world . x ;
1713+ var dy = pointer . worldY - displayObject . world . y ;
1714+
1715+ return Math . atan2 ( dy , dx ) ;
1716+ }
1717+
17011718} ;
You can’t perform that action at this time.
0 commit comments