mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 00:21:04 +00:00
The InputManager.onTouchMove
method will now check if the changed touch is over the canvas, or not, via the DOM elementFromPoint
function. This means if the touch leaves the canvas, it will now trigger the GAME_OUT
and GAME_OVER
events, where-as before this would only happen for a Mouse. If the touch isn't over the canvas, no Pointer touch move happens, just like with the mouse. Fix #5592
This commit is contained in:
parent
d36c8177b5
commit
91f72f7700
1 changed files with 25 additions and 9 deletions
|
@ -315,15 +315,18 @@ var InputManager = new Class({
|
||||||
*/
|
*/
|
||||||
boot: function ()
|
boot: function ()
|
||||||
{
|
{
|
||||||
this.canvas = this.game.canvas;
|
var game = this.game;
|
||||||
|
var events = game.events;
|
||||||
|
|
||||||
this.scaleManager = this.game.scale;
|
this.canvas = game.canvas;
|
||||||
|
|
||||||
|
this.scaleManager = game.scale;
|
||||||
|
|
||||||
this.events.emit(Events.MANAGER_BOOT);
|
this.events.emit(Events.MANAGER_BOOT);
|
||||||
|
|
||||||
this.game.events.on(GameEvents.PRE_RENDER, this.preRender, this);
|
events.on(GameEvents.PRE_RENDER, this.preRender, this);
|
||||||
|
|
||||||
this.game.events.once(GameEvents.DESTROY, this.destroy, this);
|
events.once(GameEvents.DESTROY, this.destroy, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -605,19 +608,32 @@ var InputManager = new Class({
|
||||||
{
|
{
|
||||||
var changedTouch = event.changedTouches[c];
|
var changedTouch = event.changedTouches[c];
|
||||||
|
|
||||||
// document.elementFromPoint(0,0)
|
|
||||||
|
|
||||||
for (var i = 1; i < this.pointersTotal; i++)
|
for (var i = 1; i < this.pointersTotal; i++)
|
||||||
{
|
{
|
||||||
var pointer = pointers[i];
|
var pointer = pointers[i];
|
||||||
|
|
||||||
if (pointer.active && pointer.identifier === changedTouch.identifier)
|
if (pointer.active && pointer.identifier === changedTouch.identifier)
|
||||||
|
{
|
||||||
|
var element = document.elementFromPoint(changedTouch.pageX, changedTouch.pageY);
|
||||||
|
var overCanvas = element === this.canvas;
|
||||||
|
|
||||||
|
if (!this.isOver && overCanvas)
|
||||||
|
{
|
||||||
|
this.setCanvasOver(event);
|
||||||
|
}
|
||||||
|
else if (this.isOver && !overCanvas)
|
||||||
|
{
|
||||||
|
this.setCanvasOut(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isOver)
|
||||||
{
|
{
|
||||||
pointer.touchmove(changedTouch, event);
|
pointer.touchmove(changedTouch, event);
|
||||||
|
|
||||||
this.activePointer = pointer;
|
this.activePointer = pointer;
|
||||||
|
|
||||||
changed.push(pointer);
|
changed.push(pointer);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue