mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
onDragUpdate is a new signal that is dispatched whenever a Game object enabled for input and drag is moved by a pointer (i.e. during a drag event). See the Phaser.InputHandler.enableDrag
docs for parameter details and the new Phaser Example.
This commit is contained in:
parent
eec99db8a9
commit
2b0abb67dd
3 changed files with 20 additions and 1 deletions
|
@ -300,6 +300,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* Device.firefoxVersion is a new property that contains the major Firefox version number if running within Firefox, otherwise zero.
|
||||
* Math.distanceSq will return the euclidean distance squared between the two given set of coordinates (thanks @jeremyosborne #1761 #1770)
|
||||
* StateManager.onStateChange is a new signal which is dispatched whenever the State changes from one to another. The callback you specify is sent two parameters: the string based key of the new state, and the second parameter is the string based key of the old / previous state.
|
||||
* onDragUpdate is a new signal that is dispatched whenever a Game object enabled for input and drag is moved by a pointer (i.e. during a drag event). See the `Phaser.InputHandler.enableDrag` docs for parameter details and the new Phaser Example.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ Phaser.Events.prototype = {
|
|||
if (this._onInputDown) { this._onInputDown.dispose(); }
|
||||
if (this._onInputUp) { this._onInputUp.dispose(); }
|
||||
if (this._onDragStart) { this._onDragStart.dispose(); }
|
||||
if (this._onDragUpdate) { this._onDragUpdate.dispose(); }
|
||||
if (this._onDragStop) { this._onDragStop.dispose(); }
|
||||
|
||||
if (this._onAnimationStart) { this._onAnimationStart.dispose(); }
|
||||
|
@ -131,6 +132,11 @@ Phaser.Events.prototype = {
|
|||
*/
|
||||
onDragStart: null,
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onDragUpdate - This signal is dispatched if the parent is inputEnabled and receives a drag update event from a Pointer.
|
||||
*/
|
||||
onDragUpdate: null,
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onDragStop - This signal is dispatched if the parent is inputEnabled and receives a drag stop event from a Pointer.
|
||||
*/
|
||||
|
|
|
@ -1064,6 +1064,7 @@ Phaser.InputHandler.prototype = {
|
|||
{
|
||||
this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
this.snapPoint.set(this.sprite.cameraOffset.x, this.sprite.cameraOffset.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1092,9 +1093,12 @@ Phaser.InputHandler.prototype = {
|
|||
{
|
||||
this.sprite.x = Math.round((this.sprite.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX + (this.snapOffsetX % this.snapX);
|
||||
this.sprite.y = Math.round((this.sprite.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY + (this.snapOffsetY % this.snapY);
|
||||
this.snapPoint.set(this.sprite.x, this.sprite.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.sprite.events.onDragUpdate.dispatch(this.sprite, pointer, px, py, this.snapPoint);
|
||||
|
||||
return true;
|
||||
|
||||
},
|
||||
|
@ -1202,7 +1206,15 @@ Phaser.InputHandler.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
|
||||
* Allow this Sprite to be dragged by any valid pointer.
|
||||
*
|
||||
* When the drag begins the Sprite.events.onDragStart event will be dispatched.
|
||||
*
|
||||
* When the drag completes by way of the user letting go of the pointer that was dragging the sprite, the Sprite.events.onDragStop event is dispatched.
|
||||
*
|
||||
* For the duration of the drag the Sprite.events.onDragUpdate event is dispatched. This event is only dispatched when the pointer actually
|
||||
* changes position and moves. The event sends 5 parameters: `sprite`, `pointer`, `dragX`, `dragY` and `snapPoint`.
|
||||
*
|
||||
* @method Phaser.InputHandler#enableDrag
|
||||
* @param {boolean} [lockCenter=false] - If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.
|
||||
* @param {boolean} [bringToTop=false] - If true the Sprite will be bought to the top of the rendering list in its current Group.
|
||||
|
|
Loading…
Add table
Reference in a new issue