Skip to content

Commit 3eba508

Browse files
committed
Sprite.events.onDragStart has 2 new parameters x and y which is the position of the Sprite before the drag was started. The full list of parameters is: (sprite, pointer, x, y). This allows you to retain the position of the Sprite prior to dragging should dragFromCenter have been enabled (thanks @vulvulune phaserjs#1583)
1 parent 2ba6e05 commit 3eba508

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Version 2.3.0 - "Tarabon" - in dev
6969
### Updates
7070

7171
* TypeScript definitions fixes and updates (thanks @Phaiax @Bilge @clark-stevenson @TimvdEijnden @belohlavek @ivw @vulvulune)
72+
* There is a new TypeScript defs file (phaser.comments.d.ts) which now has all of the jsdocs included! (thanks @vulvulune #1559)
7273
* Sound.fadeTween is now used for Sound.fadeIn and Sound.fadeOut audio tweens.
7374
* Sound.stop and Sound.destroy now halt a fade tween if in effect.
7475
* Arcade Physics `computeVelocity` now allows a max velocity of 0 allowing movement to be constrained to a single axis (thanks @zekoff #1594)
@@ -77,6 +78,7 @@ Version 2.3.0 - "Tarabon" - in dev
7778
* Added missing plugins member in Phaser.Game class (thanks @Bilge #1568)
7879
* Lots of JSDocs fixes (thanks @vulvulune @micahjohnston @Marchys)
7980
* TilemapLayer.getTiles now returns a copy of the Tiles found by the method, rather than references to the original Tile objects, so you're free to modify them without corrupting the source (thanks @Leekao #1585)
81+
* Sprite.events.onDragStart has 2 new parameters `x` and `y` which is the position of the Sprite before the drag was started. The full list of parameters is: `(sprite, pointer, x, y)`. This allows you to retain the position of the Sprite prior to dragging should `dragFromCenter` have been enabled (thanks @vulvulune #1583)
8082

8183
### Bug Fixes
8284

src/input/InputHandler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,9 @@ Phaser.InputHandler.prototype = {
12561256
*/
12571257
startDrag: function (pointer) {
12581258

1259+
var x = this.sprite.x;
1260+
var y = this.sprite.y;
1261+
12591262
this.isDragged = true;
12601263
this._draggedPointerID = pointer.id;
12611264
this._pointerData[pointer.id].isDragged = true;
@@ -1293,7 +1296,7 @@ Phaser.InputHandler.prototype = {
12931296
this.sprite.bringToTop();
12941297
}
12951298

1296-
this.sprite.events.onDragStart$dispatch(this.sprite, pointer);
1299+
this.sprite.events.onDragStart$dispatch(this.sprite, pointer, x, y);
12971300

12981301
},
12991302

0 commit comments

Comments
 (0)