Class: TouchManager

Phaser.Input.Touch. TouchManager

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.


new TouchManager(inputManager)

Parameters:
Name Type Description
inputManager Phaser.Input.InputManager

A reference to the Input Manager.

Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 15)

Members


capture :boolean

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

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/input/touch/TouchManager.js (Line 45)

enabled :boolean

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

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/input/touch/TouchManager.js (Line 55)

manager :Phaser.Input.InputManager

A reference to the Input Manager.

Type:
Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 36)

onTouchCancel :function

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

Type:
  • function
Since: 3.15.0
Source: src/input/touch/TouchManager.js (Line 126)

onTouchCancelWindow :function

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
Source: src/input/touch/TouchManager.js (Line 136)

onTouchEnd :function

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

Type:
  • function
Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 106)

onTouchEndWindow :function

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
Source: src/input/touch/TouchManager.js (Line 116)

onTouchMove :function

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

Type:
  • function
Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 96)

onTouchOut :function

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

Type:
  • function
Since: 3.16.0
Source: src/input/touch/TouchManager.js (Line 156)

onTouchOver :function

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

Type:
  • function
Since: 3.16.0
Source: src/input/touch/TouchManager.js (Line 146)

onTouchStart :function

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

Type:
  • function
Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 76)

onTouchStartWindow :function

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
Source: src/input/touch/TouchManager.js (Line 86)

target :any

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
Source: src/input/touch/TouchManager.js (Line 66)

Methods


destroy()

Destroys this Touch Manager instance.

Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 390)

disableContextMenu()

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.

Since: 3.20.0
Source: src/input/touch/TouchManager.js (Line 200)
Returns:

This Touch Manager instance.

Type
Phaser.Input.Touch.TouchManager

startListeners()

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
Source: src/input/touch/TouchManager.js (Line 223)

stopListeners()

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

Since: 3.0.0
Source: src/input/touch/TouchManager.js (Line 365)