Skip to content

Commit 13d8f33

Browse files
committed
Drag events.
1 parent fb8da7a commit 13d8f33

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/input/InputHandler.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ Phaser.InputHandler = function (sprite)
281281
this.onOut = new Phaser.Signal();
282282
this.onDown = new Phaser.Signal();
283283
this.onUp = new Phaser.Signal();
284+
this.onDragStart = new Phaser.Signal();
285+
this.onDragUpdate = new Phaser.Signal();
286+
this.onDragStop = new Phaser.Signal();
284287

285288
};
286289

@@ -1275,7 +1278,7 @@ Phaser.InputHandler.prototype = {
12751278
}
12761279
}
12771280

1278-
this.sprite.events.onDragUpdate.dispatch(this.sprite, pointer, px, py, this.snapPoint, fromStart);
1281+
this.onDragUpdate.dispatch(this.sprite, pointer, px, py, this.snapPoint, fromStart);
12791282

12801283
return true;
12811284

@@ -1417,8 +1420,8 @@ Phaser.InputHandler.prototype = {
14171420
* @param {Phaser.Rectangle} [boundsRect=null] - If you want to restrict the drag of this sprite to a specific Rectangle, pass the Phaser.Rectangle here, otherwise it's free to drag anywhere.
14181421
* @param {Phaser.Sprite} [boundsSprite=null] - If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here.
14191422
*/
1420-
enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) {
1421-
1423+
enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
1424+
{
14221425
if (lockCenter === undefined) { lockCenter = false; }
14231426
if (bringToTop === undefined) { bringToTop = false; }
14241427
if (pixelPerfect === undefined) { pixelPerfect = false; }
@@ -1476,8 +1479,8 @@ Phaser.InputHandler.prototype = {
14761479
* @method Phaser.InputHandler#startDrag
14771480
* @param {Phaser.Pointer} pointer
14781481
*/
1479-
startDrag: function (pointer) {
1480-
1482+
startDrag: function (pointer)
1483+
{
14811484
var x = this.sprite.x;
14821485
var y = this.sprite.y;
14831486

@@ -1489,6 +1492,7 @@ Phaser.InputHandler.prototype = {
14891492

14901493
this._pointerData[pointer.id].isDragged = true;
14911494

1495+
/*
14921496
if (this.sprite.fixedToCamera)
14931497
{
14941498
if (this.dragFromCenter)
@@ -1513,18 +1517,23 @@ Phaser.InputHandler.prototype = {
15131517
15141518
this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(pointer.x), this.sprite.y - this.globalToLocalY(pointer.y));
15151519
}
1520+
*/
1521+
1522+
this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(pointer.x), this.sprite.y - this.globalToLocalY(pointer.y));
15161523

15171524
this.updateDrag(pointer, true);
15181525

1526+
/*
15191527
if (this.bringToTop)
15201528
{
15211529
this._dragPhase = true;
15221530
this.sprite.bringToTop();
15231531
}
1532+
*/
15241533

15251534
this.dragStartPoint.set(x, y);
15261535

1527-
this.sprite.events.onDragStart$dispatch(this.sprite, pointer, x, y);
1536+
this.onDragStart.dispatch(this.sprite, pointer, x, y);
15281537

15291538
this._pendingDrag = false;
15301539

@@ -1594,7 +1603,7 @@ Phaser.InputHandler.prototype = {
15941603
}
15951604
}
15961605

1597-
this.sprite.events.onDragStop$dispatch(this.sprite, pointer);
1606+
this.onDragStop.dispatch(this.sprite, pointer);
15981607

15991608
if (this.checkPointerOver(pointer) === false)
16001609
{

0 commit comments

Comments
 (0)