Phaser API Documentation

  Version: 
Filter

The Touch Manager is a helper class that belongs to the Input Manager.

Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing.

You do not need to create this class directly, the Input Manager will create an instance of it automatically.

Constructor:

new TouchManager(inputManager)

Parameters:

name type description
inputManager Phaser.Input.InputManager

A reference to the Input Manager.

Since: 3.0.0

Members

capture: boolean
Focus
Focus

Description:

If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully.

Type:
boolean
Default: true
Since: 3.0.0
Focus
Focus
enabled: boolean
Focus
Focus

Description:

A boolean that controls if the Touch Manager is enabled or not. Can be toggled on the fly.

Type:
boolean
Default: false
Since: 3.0.0
Focus
Focus

Description:

A reference to the Input Manager.

Type:
Since: 3.0.0
Focus
Focus
onTouchCancel: function
Focus
Focus

Description:

The Touch Cancel event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.15.0
Focus
Focus
onTouchCancelWindow: function
Focus
Focus

Description:

The Touch Cancel event handler function specifically for events on the Window. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.18.0
Focus
Focus
onTouchEnd: function
Focus
Focus

Description:

The Touch End event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.0.0
Focus
Focus
onTouchEndWindow: function
Focus
Focus

Description:

The Touch End event handler function specifically for events on the Window. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.17.0
Focus
Focus
onTouchMove: function
Focus
Focus

Description:

The Touch Move event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.0.0
Focus
Focus
onTouchOut: function
Focus
Focus

Description:

The Touch Out event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.16.0
Focus
Focus
onTouchOver: function
Focus
Focus

Description:

The Touch Over event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.16.0
Focus
Focus
onTouchStart: function
Focus
Focus

Description:

The Touch Start event handler function. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.0.0
Focus
Focus
onTouchStartWindow: function
Focus
Focus

Description:

The Touch Start event handler function specifically for events on the Window. Initially empty and bound in the startListeners method.

Type:
function
Since: 3.17.0
Focus
Focus
target: any
Focus
Focus

Description:

The Touch Event target, as defined in the Game Config. Typically the canvas to which the game is rendering, but can be any interactive DOM element.

Type:
any
Since: 3.0.0
Focus
Focus

Methods

<private> boot()
Focus
Focus

Description:

The Touch Manager boot process.

Since: 3.0.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys this Touch Manager instance.

Since: 3.0.0
Focus
Focus
disableContextMenu()
Focus
Focus

Description:

Attempts to disable the context menu from appearing if you touch-hold on the browser.

Works by listening for the contextmenu event and prevent defaulting it.

Use this if you need to disable the OS context menu on mobile.

Returns:
Description:

This Touch Manager instance.

Since: 3.20.0
Focus
Focus
startListeners()
Focus
Focus

Description:

Starts the Touch Event listeners running as long as an input target is set.

This method is called automatically if Touch Input is enabled in the game config, which it is by default. However, you can call it manually should you need to delay input capturing until later in the game.

Since: 3.0.0
Focus
Focus
stopListeners()
Focus
Focus

Description:

Stops the Touch Event listeners. This is called automatically and does not need to be manually invoked.

Since: 3.0.0
Focus
Focus