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.
You should not normally access this class directly, but instead use a Phaser.Pointer object which normalises all game input for you.
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source:
- src/input/Touch.js line 16
Members
-
callbackContext : object
-
The context under which callbacks are called.
Type:
- object
- Source:
- src/input/Touch.js line 33
-
enabled : boolean
-
Touch events will only be processed if enabled.
Type:
- boolean
- Default Value:
-
- true
- Source:
- src/input/Touch.js line 28
-
event : TouchEvent
-
The browser touch DOM event. Will be set to null if no touch event has ever been received.
Type:
- TouchEvent
- Source:
- src/input/Touch.js line 75
-
game : Phaser.Game
-
A reference to the currently running game.
Type:
- Source:
- src/input/Touch.js line 21
-
preventDefault : boolean
-
If true the TouchEvent will have prevent.default called on it.
Type:
- boolean
- Default Value:
-
- true
- Source:
- src/input/Touch.js line 69
-
touchCancelCallback : function
-
A callback that can be fired on a touchCancel event.
Type:
- function
- Source:
- src/input/Touch.js line 63
-
touchEndCallback : function
-
A callback that can be fired on a touchEnd event.
Type:
- function
- Source:
- src/input/Touch.js line 48
-
touchEnterCallback : function
-
A callback that can be fired on a touchEnter event.
Type:
- function
- Source:
- src/input/Touch.js line 53
-
touchLeaveCallback : function
-
A callback that can be fired on a touchLeave event.
Type:
- function
- Source:
- src/input/Touch.js line 58
-
touchMoveCallback : function
-
A callback that can be fired on a touchMove event.
Type:
- function
- Source:
- src/input/Touch.js line 43
-
touchStartCallback : function
-
A callback that can be fired on a touchStart event.
Type:
- function
- Source:
- src/input/Touch.js line 38
Methods
-
addTouchLockCallback() deprecated
-
Adds a callback that is fired when a browser touchstart or touchend event is received.
- Deprecated:
-
- Use Phaser.Input#addTouchLockCallback instead.
- Source:
- src/input/Touch.js line 175
-
consumeTouchMove()
-
Consumes all touchmove events on the document (only enable this if you know you need it!).
- Source:
- src/input/Touch.js line 193
-
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:
- src/input/Touch.js line 243
-
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:
- src/input/Touch.js line 352
-
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:
- src/input/Touch.js line 277
-
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:
- src/input/Touch.js line 304
-
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:
- src/input/Touch.js line 326
-
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:
- src/input/Touch.js line 207
-
removeTouchLockCallback() deprecated
-
Removes the callback at the defined index from the touchLockCallbacks array.
- Deprecated:
-
- Use Phaser.Input#removeTouchLockCallback instead.
- Source:
- src/input/Touch.js line 183
-
start()
-
Starts the event listeners running.
- Source:
- src/input/Touch.js line 123
-
stop()
-
Stop the event listeners.
- Source:
- src/input/Touch.js line 383