new MSPointer(game)
The MSPointer class handles pointer interactions with the game via the Pointer Events API. (It's named after the nonstandard MSPointerEvent, ancestor of the current API.)
It's currently supported in IE 10+, Edge, Chrome (including Android), and Opera.
You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you including accurate button handling.
Phaser does not yet support chorded button interactions.
You can disable Phaser's use of Pointer Events by any of three ways:
new Phaser.Game({ mspointer: false });
// **Before** `new Phaser.Game(…)`:
Phaser.Device.onInitialized.add(function () {
this.mspointer = false;
});
// Once, in the earliest State `init` or `create` callback (e.g., Boot):
this.input.mspointer.stop();
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source:
- src/input/MSPointer.js line 39
Members
-
<readonly> active : boolean
-
Whether the input handler is active.
Type:
- boolean
- Source:
- src/input/MSPointer.js line 103
-
callbackContext : object
-
The context under which callbacks are called (defaults to game).
Type:
- object
- Source:
- src/input/MSPointer.js line 56
-
capture : boolean
-
If true the PointerEvent will call preventDefault(), canceling the corresponding MouseEvent or TouchEvent.
If the Mouse handler is active as well, you should set this to true to avoid duplicate events.
"Mouse events can only be prevented when the pointer is down. Hovering pointers (e.g. a mouse with no buttons pressed) cannot have their mouse events prevented. And, the
mouseover
andmouseout
events are never prevented (even if the pointer is down)."Type:
- boolean
-
enabled : boolean
-
PointerEvent input will only be processed if enabled.
Type:
- boolean
- Default Value:
-
- true
- Source:
- src/input/MSPointer.js line 110
-
event : MSPointerEvent | PointerEvent | null
-
The most recent PointerEvent from the browser. Will be null if no event has ever been received. Access this property only inside a Pointer event handler and do not keep references to it.
Type:
- MSPointerEvent | PointerEvent | null
- Source:
- src/input/MSPointer.js line 95
-
game : Phaser.Game
-
A reference to the currently running game.
Type:
- Source:
- src/input/MSPointer.js line 45
-
<protected> input : Phaser.Input
-
A reference to the Phaser Input Manager.
Type:
- Source:
- src/input/MSPointer.js line 51
-
pointerDownCallback : function
-
A callback that can be fired on a MSPointerDown event.
Type:
- function
- Source:
- src/input/MSPointer.js line 61
-
pointerMoveCallback : function
-
A callback that can be fired on a MSPointerMove event.
Type:
- function
- Source:
- src/input/MSPointer.js line 66
-
pointerUpCallback : function
-
A callback that can be fired on a MSPointerUp event.
Type:
- function
- Source:
- src/input/MSPointer.js line 71
Methods
-
onPointerDown(event)
-
The function that handles the PointerDown event.
Parameters:
Name Type Description event
PointerEvent The native DOM event.
- Source:
- src/input/MSPointer.js line 234
-
onPointerMove(event)
-
The function that handles the PointerMove event.
Parameters:
Name Type Description event
PointerEvent The native DOM event.
- Source:
- src/input/MSPointer.js line 275
-
onPointerOut(event)
-
The internal method that handles the pointer out event from the browser.
Parameters:
Name Type Description event
PointerEvent The native event from the browser. This gets stored in MSPointer.event.
- Source:
- src/input/MSPointer.js line 434
-
onPointerOut(event)
-
The internal method that handles the pointer out event from the browser.
Parameters:
Name Type Description event
PointerEvent The native event from the browser. This gets stored in MSPointer.event.
- Source:
- src/input/MSPointer.js line 378
-
onPointerUp(event)
-
The function that handles the PointerUp event.
Parameters:
Name Type Description event
PointerEvent The native DOM event.
- Source:
- src/input/MSPointer.js line 313
-
onPointerUpGlobal(event)
-
The internal method that handles the mouse up event from the window.
Parameters:
Name Type Description event
PointerEvent The native event from the browser. This gets stored in MSPointer.event.
- Source:
- src/input/MSPointer.js line 353
-
start()
-
Starts the event listeners running.
- Source:
- src/input/MSPointer.js line 152
-
stop()
-
Stop the event listeners.
- Source:
- src/input/MSPointer.js line 471