Pointers Class
Controls pointer input (mouse, touch, pen, etc) or all pointers tracked by the game
Constructor
Item Index
Properties
Methods
emit
-
type
-
data
Emits an event which will run all registered listeners for the event type
Parameters:
-
type
StringThe event name to emit
-
data
MixedAny data you want passed along with the event
Returns:
Returns itself.
off
-
type
-
listener
Removes a listener function for an event type
Parameters:
-
type
StringThe event name to emit
-
listener
FunctionThe function to remove
Returns:
Returns itself.
on
-
type
-
listener
Registers a listener function to be run on an event occurance
Parameters:
-
type
StringThe event name to listen for
-
listener
FunctionThe function to execute when the event happens
Returns:
Returns itself.
once
-
type
-
listener
Registers a one-time callback for an event
Parameters:
-
type
StringThe event name to listen for
-
listener
Functionthe callback to call when the event occurs
Returns:
Returns itself.
onPointer
-
name
-
evt
Callback that is called when a pointer event occurs.
Parameters:
-
name
StringThe name of the pointer event with out the 'pointer' prefix
-
evt
DOMEventThe DOM Event
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
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
ObjectThe pointer instances currently being used, keyed by an ID
Events
cancel
Fired when a pointer event is canceled
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointercancel' event
down
Fired when a pointer is pressed on the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerdown' event
enter
Fired when a pointer enters the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerenter' event
leave
Fired when a pointer leaves the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerleave' event
move
Fired when a pointer is moved while on the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointermove' event
out
Fired when a pointer moves out of the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerout' event
over
Fired when a pointer moves over the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerover' event
up
Fired when a pointer is released off the canvas
Event Payload:
-
pointer
PointerThe pointer instance that had a 'pointerup' event