@@ -5792,10 +5792,16 @@ var Phaser;
57925792 }
57935793 };
57945794 Input.prototype._touchedHandler = function (pointer) {
5795- this._pointerData[pointer.id].isDown = true;
5796- this._pointerData[pointer.id].isUp = false;
5797- this._pointerData[pointer.id].timeDown = this.game.time.now;
5798- this._sprite.events.onInputDown.dispatch(this._sprite, pointer);
5795+ if(this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) {
5796+ this._pointerData[pointer.id].isDown = true;
5797+ this._pointerData[pointer.id].isUp = false;
5798+ this._pointerData[pointer.id].timeDown = this.game.time.now;
5799+ this._sprite.events.onInputDown.dispatch(this._sprite, pointer);
5800+ // Star drag
5801+ if(this.draggable) {
5802+ this.startDrag(pointer);
5803+ }
5804+ }
57995805 };
58005806 Input.prototype._releasedHandler = function (pointer) {
58015807 this._pointerData[pointer.id].isDown = false;
@@ -5812,12 +5818,11 @@ var Phaser;
58125818 this.stopDrag(pointer);
58135819 return;
58145820 }
5815- // something wrong here, should use _dragPoint as well I think somehow
58165821 if(this.allowHorizontalDrag) {
5817- this._sprite.x = pointer.x - this.dragOffset.x;
5822+ this._sprite.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
58185823 }
58195824 if(this.allowVerticalDrag) {
5820- this._sprite.y = pointer.y - this.dragOffset.y;
5825+ this._sprite.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
58215826 }
58225827 if(this.boundsRect) {
58235828 this.checkBoundsRect();
@@ -5940,9 +5945,10 @@ var Phaser;
59405945 this._pointerData[pointer.id].isDragged = true;
59415946 if(this.dragFromCenter) {
59425947 // Move the sprite to the middle of the pointer
5943- this.dragOffset.setTo(this._sprite.frameBounds.halfWidth, this._sprite.frameBounds.halfHeight);
5948+ this._dragPoint.setTo(-this._sprite.frameBounds.halfWidth, -this._sprite.frameBounds.halfHeight);
5949+ } else {
5950+ this._dragPoint.setTo(this._sprite.x - pointer.x, this._sprite.y - pointer.y);
59445951 }
5945- this._dragPoint.setTo(pointer.x - this._sprite.x - this.dragOffset.x, pointer.y - this._sprite.y - this.dragOffset.y);
59465952 };
59475953 Input.prototype.stopDrag = /**
59485954 * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
0 commit comments