API Docs for: v0.1.0
Show:

Pointers Class

Extends Input

Controls pointer input (mouse, touch, pen, etc) or all pointers tracked by the game

Constructor

Pointers

(
  • game
)

Parameters:

  • game Game

    The game instance this input belongs to

Methods

emit

(
  • type
  • data
)
Mixed chainable

Emits an event which will run all registered listeners for the event type

Parameters:

  • type String

    The event name to emit

  • data Mixed

    Any data you want passed along with the event

Returns:

Mixed:

Returns itself.

off

(
  • type
  • listener
)
Mixed chainable

Removes a listener function for an event type

Parameters:

  • type String

    The event name to emit

  • listener Function

    The function to remove

Returns:

Mixed:

Returns itself.

on

(
  • type
  • listener
)
Mixed chainable

Registers a listener function to be run on an event occurance

Parameters:

  • type String

    The event name to listen for

  • listener Function

    The function to execute when the event happens

Returns:

Mixed:

Returns itself.

once

(
  • type
  • listener
)
Mixed chainable

Registers a one-time callback for an event

Parameters:

  • type String

    The event name to listen for

  • listener Function

    the callback to call when the event occurs

Returns:

Mixed:

Returns itself.

onPointer

(
  • name
  • evt
)
private

Callback that is called when a pointer event occurs.

Parameters:

  • name String

    The name of the pointer event with out the 'pointer' prefix

  • evt DOMEvent

    The DOM Event

update

(
  • dt
)
Pointers private

Called internally every frame. Updates all the pointers

Parameters:

  • dt Number

    The delta time (in seconds) since the last update

Returns:

Pointers:

Returns iteself for chainability

Properties

clickDelay

Number

The time that must pass between a down (touchstart/mousedown) and up (touchend/mouseup) event for it to be considered a "click" event, in milliseconds

Default: 200

doubleClickDelay

Number

The max time that can pass between two click events for it to be considered a "doubleclick" event, in milliseconds

Default: 300

game

Game

Inherited from Input: src\input\Input.js:16

The game instance this input belongs to

holdDelay

Number

The time that must pass after a down event for it to be considered a "hold" event, in milliseconds

Default: 2000

maxPointers

Number

The max number of pointers to track

Default: 10

pointers

Object

The pointer instances currently being used, keyed by an ID

Events

cancel

Fired when a pointer event is canceled

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointercancel' event

down

Fired when a pointer is pressed on the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerdown' event

enter

Fired when a pointer enters the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerenter' event

leave

Fired when a pointer leaves the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerleave' event

move

Fired when a pointer is moved while on the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointermove' event

out

Fired when a pointer moves out of the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerout' event

over

Fired when a pointer moves over the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerover' event

up

Fired when a pointer is released off the canvas

Event Payload:

  • pointer Pointer

    The pointer instance that had a 'pointerup' event