These docs are for Phaser 2.3.0 Phaser 3 docs can be found on GitHub pages.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. Touch

new Touch(game)

Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch.

Parameters
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source code: input/Touch.js (Line 14)

Public Properties

callbackContext : Object

The context under which callbacks are called.

Source code: input/Touch.js (Line 31)

enabled : boolean

Touch events will only be processed if enabled.

Default Value
  • true
Source code: input/Touch.js (Line 26)

event :TouchEvent

The browser touch DOM event. Will be set to null if no touch event has ever been received.

Default Value
  • null
Source code: input/Touch.js (Line 73)

game : Phaser.Game

A reference to the currently running game.

Source code: input/Touch.js (Line 19)

preventDefault : boolean

If true the TouchEvent will have prevent.default called on it.

Default Value
  • true
Source code: input/Touch.js (Line 67)

touchCancelCallback : Function

A callback that can be fired on a touchCancel event.

Source code: input/Touch.js (Line 61)

touchEndCallback : Function

A callback that can be fired on a touchEnd event.

Source code: input/Touch.js (Line 46)

touchEnterCallback : Function

A callback that can be fired on a touchEnter event.

Source code: input/Touch.js (Line 51)

touchLeaveCallback : Function

A callback that can be fired on a touchLeave event.

Source code: input/Touch.js (Line 56)

touchMoveCallback : Function

A callback that can be fired on a touchMove event.

Source code: input/Touch.js (Line 41)

touchStartCallback : Function

A callback that can be fired on a touchStart event.

Source code: input/Touch.js (Line 36)

Public Methods

consumeTouchMove()

Consumes all touchmove events on the document (only enable this if you know you need it!).

Source code: input/Touch.js (Line 175)

onTouchCancel(event)

Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). Occurs for example on iOS when you put down 4 fingers and the app selector UI appears.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 223)

onTouchEnd(event)

The handler for the touchend events.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 332)

onTouchEnter(event)

For touch enter and leave its a list of the touch points that have entered or left the target. Doesn't appear to be supported by most browsers on a canvas element yet.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 257)

onTouchLeave(event)

For touch enter and leave its a list of the touch points that have entered or left the target. Doesn't appear to be supported by most browsers on a canvas element yet.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 284)

onTouchMove(event)

The handler for the touchmove events.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 306)

onTouchStart(event)

The internal method that handles the touchstart event from the browser.

Parameters
Name Type Description
event TouchEvent

The native event from the browser. This gets stored in Touch.event.

Source code: input/Touch.js (Line 189)

start()

Starts the event listeners running.

Source code: input/Touch.js (Line 121)

stop()

Stop the event listeners.

Source code: input/Touch.js (Line 361)