mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 07:04:31 +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 ()
|
||||
{
|
||||
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.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];
|
||||
|
||||
// document.elementFromPoint(0,0)
|
||||
|
||||
for (var i = 1; i < this.pointersTotal; i++)
|
||||
{
|
||||
var pointer = pointers[i];
|
||||
|
||||
if (pointer.active && pointer.identifier === changedTouch.identifier)
|
||||
{
|
||||
pointer.touchmove(changedTouch, event);
|
||||
var element = document.elementFromPoint(changedTouch.pageX, changedTouch.pageY);
|
||||
var overCanvas = element === this.canvas;
|
||||
|
||||
this.activePointer = pointer;
|
||||
if (!this.isOver && overCanvas)
|
||||
{
|
||||
this.setCanvasOver(event);
|
||||
}
|
||||
else if (this.isOver && !overCanvas)
|
||||
{
|
||||
this.setCanvasOut(event);
|
||||
}
|
||||
|
||||
changed.push(pointer);
|
||||
if (this.isOver)
|
||||
{
|
||||
pointer.touchmove(changedTouch, event);
|
||||
|
||||
this.activePointer = pointer;
|
||||
|
||||
changed.push(pointer);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue