Class: Pointer

Pointer(domElement, canvas)

new Pointer(domElement, canvas)

Pointer object is used to called input from the user, works for booth mouse or touch screens. It is responsible for synchronizing user input with the render of the graphics.
Parameters:
Name Type Description
domElement Element DOM element to create the pointer events.
canvas Element Canvas DOM element where the content is being drawn.
Source:

Members

(static) BACK :number

Back pointer navigation button.
Type:
  • number
Source:

(static) FORWARD :number

Forward pointer navigation button.
Type:
  • number
Source:

(static) LEFT :number

Left pointer button.
Type:
  • number
Source:

(static) MIDDLE :number

Middle pointer button.
Type:
  • number
Source:

(static) RIGHT :number

Right pointer button.
Type:
  • number
Source:

canvas :Element

Canvas attached to this pointer instance used to calculate position and delta in element space coordinates.
Type:
  • Element
Source:

delta :Vector2

Pointer movement (coordinates in window space). Since the last update. This value is accumulated from multiple mouse triggered events between updated.
Type:
Source:

domElement :Element

DOM element where to attach the pointer events.
Type:
  • Element
Source:

doubleClicked :boolean

Indicates a button of the pointer was double clicked.
Type:
  • boolean
Source:

events :EventManager

Event manager responsible for updating the raw data variables. Different events are used depending on the host platform. When the update method is called the raw data is reset.
Type:
Source:

keys :Array.<number>

Array with pointer buttons status.
Type:
  • Array.<number>
Source:

position :Vector2

Pointer position inside of the window (coordinates in window space). This value is accumulated from multiple mouse triggered events between updated.
Type:
Source:

wheel :number

Pointer scroll wheel movement, since the last update.
Type:
  • number
Source:

Methods

(static) buttonDoubleClicked(button) → {boolean}

Check if pointer button was double clicked.
Parameters:
Name Type Description
button Number Button to check status of
Source:
Returns:
True if some pointer button was just double clicked
Type
boolean

(static) buttonJustPressed(button) → {boolean}

Check if a pointer button was just pressed.
Parameters:
Name Type Description
button Number Button to check status of
Source:
Returns:
True if button was just pressed
Type
boolean

(static) buttonJustReleased(button) → {boolean}

Check if a pointer button was just released.
Parameters:
Name Type Description
button Number Button to check status of
Source:
Returns:
True if button was just released
Type
boolean

(static) buttonPressed(button) → {boolean}

Check if pointer button is currently pressed.
Parameters:
Name Type Description
button Number Button to check status of
Source:
Returns:
True if button is currently pressed
Type
boolean

(static) create()

Create pointer events to collect input data. Should be called before using the pointer object.
Source:

(static) dispose()

Dispose pointer events, should be called after the objects is no longer required. If not called leaves the window events created leaving a memory/code leak.
Source:

(static) insideCanvas() → {boolean}

Check if pointer is inside attached canvas (updated async).
Source:
Returns:
True if pointer is currently inside the canvas
Type
boolean

(static) setCanvas(element)

Element to be used for coordinates calculation relative to that canvas.
Parameters:
Name Type Description
element DOM Canvas to be attached to the Pointer instance
Source:

(static) update()

Update pointer buttons state, position, wheel and delta synchronously. Should be called every frame on the update loop before reading any values from the pointer.
Source:

(static) updateKey(button, action)

Update a pointer button.
Parameters:
Name Type Description
button Number
action Number
Source:

(static) updatePosition(x, y, xDiff, yDiff)

Update pointer position.
Parameters:
Name Type Description
x Number
y Number
xDiff Number
yDiff Number
Source: