API Docs for: 1.4.0
Show:

Kiwi.Input.Touch Class

Defined in: src\input\Touch.ts:10
Module: Input
Parent Module: Kiwi

Handles the dispatching and management of touch based events for the game. When the Touch manager is created TEN finger objects are created and used when the user interacts with the screen. Those finger are what you can use to create games that make the most out of multitouch events.

Constructor

Kiwi.Input.Touch

(
  • game
)
Touch

Parameters:

  • game Game

    the game that this touch manager belongs to.

Returns:

Touch:

This object.

Methods

_cancelFinger

(
  • event
  • id
)
private

This method is in charge of cancelling (removing) a "finger". You have to pass this method a id which is used to idenfied the finger that was cancelled.

Parameters:

  • event Any
  • id Number

_deregisterFinger

(
  • event
  • id
)
private

This method is in charge of deregistering (removing) a "finger" when it has been released, You have to pass this method a id which is used to identfy the finger to deregister.

Parameters:

  • event Any
  • id Number

_enterFinger

(
  • event
  • id
)
private

This method is in charge of creating and assigning (removing) a "finger" when it has entered the dom element. You have to pass this method a id which is used to idenfied the finger that was cancelled.

Parameters:

  • event Any
  • id Number

_leaveFinger

(
  • event
  • id
)
private

This method is in charge of removing an assigned "finger" when it has left the DOM Elemetn. You have to pass this method a id which is used to idenfied the finger that left.

Parameters:

  • event Any
  • id Number

_moveFinger

(
  • event
  • id
)
private

This method is in charge of updating the coordinates of a "finger" when it has moved.. You have to pass this method a id which is used to idenfied the finger that moved.

Parameters:

  • event Any
  • id Number

_registerFinger

(
  • event
  • id
)
private

This method is in charge of registering a "finger" (either from a Touch/Pointer start method) and assigning it a Finger, You have to pass this method a id which is used to idenfied when released/cancelled.

Parameters:

  • event Any
  • id Number

boot

() public

An internal Kiwi method that runs when the DOM is loaded and the touch manager can now 'boot' up.

consumeTouchMove

(
  • event
)
public

Prevent iOS bounce-back (doesn't work?)

Parameters:

  • event Any

objType

() String public

The type of object that this is.

Returns:

String:

"TouchManager"

onPointerCancel

(
  • event
)
private

Event that is fired by a pointer event listener upon a pointer canceling for some reason.

Parameters:

  • event PointerEvent

onPointerEnd

(
  • event
)
private

Event that is fired by a pointer event listener upon a pointer being released.

Parameters:

  • event PointerEvent

onPointerEnter

(
  • event
)
private

Event that is fired by a pointer event listener upon a pointer entering the DOM Element the event listener is attached to.

Parameters:

  • event PointerEvent

onPointerLeave

(
  • event
)
private

Event that is fired by a pointer event listener upon a pointer being leaving the DOM Element the event listener is attached to.

Parameters:

  • event PointerEvent

onPointerMove

(
  • event
)

Event that is fired by a pointer event listener upon a pointer moving.

Parameters:

  • event PointerEvent

onPointerStart

(
  • event
)
private

Event that is fired when a pointer is initially pressed.

Parameters:

  • event PointerEvent

onTouchCancel

(
  • event
)
private

Doesn't appear to be supported by most browsers yet but if it was it would fire events when a touch is canceled. http://www.w3.org/TR/touch-events/#dfn-touchcancel

Parameters:

  • event Any

onTouchEnd

(
  • event
)
private

When a touch event gets released. https://developer.mozilla.org/en-US/docs/DOM/TouchList

Parameters:

  • event Any

onTouchEnter

(
  • event
)
private

Doesn't appear to be supported by most browsers yet. But if it was would fire events when touch events enter an element.

Parameters:

  • event Any

onTouchLeave

(
  • event
)
private

Doesn't appear to be supported by most browsers yet. Would fire events when a 'finger' leaves an element.
Would be handly for when an finger 'leaves' the stage.

Parameters:

  • event Any

onTouchMove

(
  • event
)
private

When a touch pointer moves. This method updates the appropriate pointer.

Parameters:

  • event Any

onTouchStart

(
  • event
)
private

This method runs when the a touch start event is fired by the browser and then assigns the event to a pointer that is currently not active. https://developer.mozilla.org/en-US/docs/DOM/TouchList

Parameters:

  • event Any

reset

() public

Resets all of the fingers/pointers to their default states.

start

() public

Starts up the event listeners that are being used on the touch manager.

stop

() public

This method removes all of the event listeners and thus 'stops' the touch manager.

update

() public

The update loop fro the touch manager.

Properties

_domElement

HTMLElement private

The dom element that these touch events are to take place on. This is usally set to be the stage/game container.

Default: null

_fingers

Array private

Contains a list of all of the fingers that are used for the touch events.

_game

Game private

The game that this touch manager belongs to.

_maxPointers

Number private

The developer defined maximum number of touch events. By default this is set to 10 but this can be set to be lower.

Default: 10

_onTouchCancelBind

Function private

Defined in src\input\Touch.ts:920

Available since 1.3.0

The binding of the 'onTouchCancel' method.

_onTouchEndBind

Function private

Defined in src\input\Touch.ts:890

Available since 1.3.0

The binding of the 'onTouchEnd' method.

_onTouchEnterBind

Function private

Defined in src\input\Touch.ts:900

Available since 1.3.0

The binding of the 'onTouchEnter' method.

_onTouchLeaveBind

Function private

Defined in src\input\Touch.ts:910

Available since 1.3.0

The binding of the 'onTouchLeave' method.

_onTouchMoveBind

Function private

Defined in src\input\Touch.ts:880

Available since 1.3.0

The binding of the 'onTouchMove' method.

_onTouchStartBind

Function private

Defined in src\input\Touch.ts:870

Available since 1.3.0

The binding of the 'onTouchStart' method.

finger1

Finger public

The first finger that is used for touch events.

finger10

Finger public

The tenth finger that is used for touch events.

finger2

Finger public

The second finger that is used for touch events.

finger3

Finger public

The third finger that is used for touch events.

finger4

Finger public

The fourth finger that is used for touch events.

finger5

Finger public

Finger number five that is used for touch events.

finger6

Finger public

Finger number six, that is used for touch events.

finger7

Finger public

The seventh finger used for touch events.

finger8

Finger public

Finger number eight

finger9

Finger public

The ninth finger that is used for touch events.

isDown

Boolean public

A boolean that will roughly indicate if any finger is currently down.

Default: false

isUp

Boolean public

If all the fingers are up.

Default: true

latestFinger

Finger public

The latest finger that was used for any task.

maximumPointers

Number public

Sets the maximum number of point of contact that are allowed on the game stage at one point. The maximum number of points that are allowed is 10, and the minimum is 0.

onCancel

Signal public

A Kiwi Signal that dispatches an event when a touch event is cancelled for the some reason.

onDown

Signal public

A Kiwi Signal that dispatches an event when a user presses down on the stage.

onUp

Signal public

A Kiwi Signal that dispatches an event when a user releases a finger off of the stage.

touchCancel

Signal deprecated public

A Kiwi Signal that dispatches an event when a touch event is cancelled for the some reason.

touchDown

Signal deprecated public

A Kiwi Signal that dispatches an event when a user presses down on the stage.

touchEnabled

Boolean public

If the touch inputs are enabled on the current device (and so if the events will fire) or not.

touchUp

Signal deprecated public

A Kiwi Signal that dispatches an event when a user releases a finger off of the stage.

x

Number public

Gets the position of the latest finger on the x axis.

y

Number public

Gets the position of the latest finger on the y axis.