Skip to content

Commit 18ff048

Browse files
committed
ArcadePhysics.distanceToPointer now calculates the distance in world space values.
ArcadePhysics.moveToPointer no longer goes crazy if the maxTime parameter is given and the Sprite is positioned in a larger game world (thanks @AnderbergE phaserjs#1472)
1 parent 7a066a3 commit 18ff048

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Thanks to @pnstickne for vast majority of this update.
121121
* The Loader now directly calls StateManager.loadComplete rather than the StateManager listening for the loadComplete event, because Loader.reset unbinds this event (and it's easy to accidentally remove it too)
122122
* Loader.onLoadComplete is dispatched *before* the Loader is reset. If you have a `create` method in your State please note that the Loader will have been reset before this method is called. This allows you to immediately re-use the Loader without having to first reset it manually.
123123
* World.setBounds will now adjust the World.x/y values to match those given (#1555)
124+
* ArcadePhysics.distanceToPointer now calculates the distance in world space values.
124125

125126
### Bug Fixes
126127

@@ -138,6 +139,7 @@ Thanks to @pnstickne for vast majority of this update.
138139
* Fixed issue in PIXI.Text where it was using the wrong string for descender text measurements.
139140
* Sprite.loadTexture and Image.loadTexture now no longer call `updateTexture` if the texture given is a RenderTexture. This fixes issues with RetroFonts in IE11 WebGL as well as other RenderTexture related IE11 problems (#1310 #1381 #1523)
140141
* You can now tint animated Sprites in Canvas mode. Or change the texture atlas frame of a tinted Sprite or Image. Please note that this is pretty expensive (depending in the browser), as the tint is re-applied every time the *frame changes*. The Pixi tint cache has also been removed to allow for subtle tint color shifts and to avoid blowing up memory. So use this feature sparingly! But at least it does now work (#1070)
142+
* ArcadePhysics.moveToPointer no longer goes crazy if the maxTime parameter is given and the Sprite is positioned in a larger game world (thanks @AnderbergE #1472)
141143

142144
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
143145

src/physics/arcade/World.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,7 @@ Phaser.Physics.Arcade.prototype = {
17781778
* Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used.
17791779
* The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed.
17801780
* If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()
1781+
* The distance to the Pointer is returned in screen space, not world space.
17811782
*
17821783
* @method Phaser.Physics.Arcade#distanceToPointer
17831784
* @param {any} displayObject - The Display Object to test from.
@@ -1788,8 +1789,8 @@ Phaser.Physics.Arcade.prototype = {
17881789

17891790
pointer = pointer || this.game.input.activePointer;
17901791

1791-
this._dx = displayObject.x - pointer.x;
1792-
this._dy = displayObject.y - pointer.y;
1792+
this._dx = displayObject.x - pointer.worldX;
1793+
this._dy = displayObject.y - pointer.worldY;
17931794

17941795
return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
17951796

0 commit comments

Comments
 (0)