mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Pointer.dirty is a new boolean that is set by the InputHandler. It tells the Pointer to re-check all interactive objects it may be over on the next update, regardless if it has moved position or not. This helps solve issues where you may have a Button that on click generates a pop-up window that now obscures the Button (thanks @jflowers45 #882)
This commit is contained in:
parent
b4ba7958c6
commit
dd9e7e6297
3 changed files with 27 additions and 2 deletions
|
@ -92,6 +92,7 @@ Version 2.1.0 - "Cairhien" - -in development-
|
||||||
* Device.node and Device.nodeWebKit are two new properties (thanks @videlais #1129)
|
* Device.node and Device.nodeWebKit are two new properties (thanks @videlais #1129)
|
||||||
* P2.PointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
|
* P2.PointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
|
||||||
* P2.InversePointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
|
* P2.InversePointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
|
||||||
|
* Pointer.dirty is a new boolean that is set by the InputHandler. It tells the Pointer to re-check all interactive objects it may be over on the next update, regardless if it has moved position or not. This helps solve issues where you may have a Button that on click generates a pop-up window that now obscures the Button (thanks @jflowers45 #882)
|
||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
|
|
@ -832,7 +832,7 @@ Phaser.InputHandler.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._pointerData[pointer.id].isOver === false)
|
if (this._pointerData[pointer.id].isOver === false || pointer.dirty)
|
||||||
{
|
{
|
||||||
this._pointerData[pointer.id].isOver = true;
|
this._pointerData[pointer.id].isOver = true;
|
||||||
this._pointerData[pointer.id].isOut = false;
|
this._pointerData[pointer.id].isOut = false;
|
||||||
|
@ -915,6 +915,9 @@ Phaser.InputHandler.prototype = {
|
||||||
this.sprite.events.onInputDown.dispatch(this.sprite, pointer);
|
this.sprite.events.onInputDown.dispatch(this.sprite, pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It's possible the onInputDown event created a new Sprite that is on-top of this one, so we ought to force a Pointer update
|
||||||
|
pointer.dirty = true;
|
||||||
|
|
||||||
// Start drag
|
// Start drag
|
||||||
if (this.draggable && this.isDragged === false)
|
if (this.draggable && this.isDragged === false)
|
||||||
{
|
{
|
||||||
|
@ -979,6 +982,9 @@ Phaser.InputHandler.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It's possible the onInputUp event created a new Sprite that is on-top of this one, so we ought to force a Pointer update
|
||||||
|
pointer.dirty = true;
|
||||||
|
|
||||||
// Stop drag
|
// Stop drag
|
||||||
if (this.draggable && this.isDragged && this._draggedPointerID === pointer.id)
|
if (this.draggable && this.isDragged && this._draggedPointerID === pointer.id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,6 +217,12 @@ Phaser.Pointer = function (game, id) {
|
||||||
*/
|
*/
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {boolean} dirty - A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not.
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
this.dirty = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display.
|
* @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display.
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +279,7 @@ Phaser.Pointer.prototype = {
|
||||||
this.withinGame = true;
|
this.withinGame = true;
|
||||||
this.isDown = true;
|
this.isDown = true;
|
||||||
this.isUp = false;
|
this.isUp = false;
|
||||||
|
this.dirty = false;
|
||||||
|
|
||||||
// Work out how long it has been since the last click
|
// Work out how long it has been since the last click
|
||||||
this.msSinceLastClick = this.game.time.now - this.timeDown;
|
this.msSinceLastClick = this.game.time.now - this.timeDown;
|
||||||
|
@ -319,6 +326,17 @@ Phaser.Pointer.prototype = {
|
||||||
|
|
||||||
if (this.active)
|
if (this.active)
|
||||||
{
|
{
|
||||||
|
// Force a check?
|
||||||
|
if (this.dirty)
|
||||||
|
{
|
||||||
|
if (this.game.input.interactiveItems.total > 0)
|
||||||
|
{
|
||||||
|
this.processInteractiveObjects(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._holdSent === false && this.duration >= this.game.input.holdRate)
|
if (this._holdSent === false && this.duration >= this.game.input.holdRate)
|
||||||
{
|
{
|
||||||
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
|
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers === 0))
|
||||||
|
@ -497,7 +515,6 @@ Phaser.Pointer.prototype = {
|
||||||
while (currentNode !== null);
|
while (currentNode !== null);
|
||||||
|
|
||||||
// Now we know the top-most item (if any) we can process it
|
// Now we know the top-most item (if any) we can process it
|
||||||
|
|
||||||
if (this._highestRenderObject === null)
|
if (this._highestRenderObject === null)
|
||||||
{
|
{
|
||||||
// The pointer isn't currently over anything, check if we've got a lingering previous target
|
// The pointer isn't currently over anything, check if we've got a lingering previous target
|
||||||
|
@ -666,6 +683,7 @@ Phaser.Pointer.prototype = {
|
||||||
|
|
||||||
this.pointerId = null;
|
this.pointerId = null;
|
||||||
this.identifier = null;
|
this.identifier = null;
|
||||||
|
this.dirty = false;
|
||||||
this.isDown = false;
|
this.isDown = false;
|
||||||
this.isUp = true;
|
this.isUp = true;
|
||||||
this.totalTouches = 0;
|
this.totalTouches = 0;
|
||||||
|
|
Loading…
Reference in a new issue