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.
Name | Type | Description |
---|---|---|
game | Phaser.Game | A reference to the currently running game. |
The context under which callbacks are called.
Touch events will only be processed if enabled.
The browser touch DOM event. Will be set to null if no touch event has ever been received.
A reference to the currently running game.
If true the TouchEvent will have prevent.default called on it.
A callback that can be fired on a touchCancel event.
A callback that can be fired on a touchEnd event.
A callback that can be fired on a touchEnter event.
A callback that can be fired on a touchLeave event.
An array of callbacks that will be fired every time a native touch start or touch end event is received from the browser.
This is used internally to handle audio and video unlocking on mobile devices.
To add a callback to this array please use Touch.addTouchLockCallback
.
A callback that can be fired on a touchMove event.
A callback that can be fired on a touchStart event.
Adds a callback that is fired when a browser touchstart or touchend event is received.
This is used internally to handle audio and video unlocking on mobile devices.
If the callback returns 'true' then the callback is automatically deleted once invoked.
The callback is added to the Phaser.Touch.touchLockCallbacks array and should be removed with Phaser.Touch.removeTouchLockCallback.
Name | Type | Argument | Default | Description |
---|---|---|---|---|
callback | function | The callback that will be called when a touchstart event is received. | ||
context | object | The context in which the callback will be called. | ||
onEnd | boolean | <optional> | false | Will the callback fire on a touchstart (default) or touchend event? |
Consumes all touchmove events on the document (only enable this if you know you need it!).
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.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.event. |
The handler for the touchend events.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.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.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.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.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.event. |
The handler for the touchmove events.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.event. |
The internal method that handles the touchstart event from the browser.
Name | Type | Description |
---|---|---|
event | TouchEvent | The native event from the browser. This gets stored in Touch.event. |
Removes the callback at the defined index from the Phaser.Touch.touchLockCallbacks array
Name | Type | Description |
---|---|---|
callback | function | The callback to be removed. |
context | object | The context in which the callback exists. |
True if the callback was deleted, otherwise false.
Starts the event listeners running.
Stop the event listeners.
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/Phaser.Touch.html