These docs are for an outdated version of Phaser The documentation on this page is for Phaser 2.4.4. The latest release is 2.8.1.

Constructor

Phaser. Pointer

new Pointer(game, id, pointerMode)

A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.

Parameters
Name Type Default Description
game Phaser.Game

A reference to the currently running game.

id number

The ID of the Pointer object within the game. Each game can have up to 10 active pointers.

pointerMode Phaser.PointerMode (CURSOR | CONTACT)

The operational mode of this pointer, eg. CURSOR or TOUCH.

Source code: input/Pointer.js (Line 16)

Public Properties

[static] BACK_BUTTON : number

The X1 button. This is typically the mouse Back button, but is often reconfigured. On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register.

Source code: input/Pointer.js (Line 386)

[static] ERASER_BUTTON : number

The Eraser pen button on PointerEvent supported devices only.

Source code: input/Pointer.js (Line 401)

[static] FORWARD_BUTTON : number

The X2 button. This is typically the mouse Forward button, but is often reconfigured. On Linux (GTK) this is unsupported. On Windows if advanced pointer software (such as IntelliPoint) is installed this doesn't register.

Source code: input/Pointer.js (Line 394)

[static] LEFT_BUTTON : number

The Left Mouse button, or in PointerEvent devices a Touch contact or Pen contact.

Source code: input/Pointer.js (Line 364)

[static] MIDDLE_BUTTON : number

The Middle Mouse button.

Source code: input/Pointer.js (Line 378)

[static] NO_BUTTON : number

No buttons at all.

Source code: input/Pointer.js (Line 357)

[static] RIGHT_BUTTON : number

The Right Mouse button, or in PointerEvent devices a Pen contact with a barrel button.

Source code: input/Pointer.js (Line 371)

active : boolean

An active pointer is one that is currently pressed down on the display. A Mouse is always active.

Source code: input/Pointer.js (Line 305)

backButton : Phaser.DeviceButton

If this Pointer is a Mouse or Pen / Stylus then you can access its X1 (back) button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Please see the DeviceButton docs for details on browser button limitations.

Source code: input/Pointer.js (Line 120)

button :any

The button property of the most recent DOM event when this Pointer is started. You should not rely on this value for accurate button detection, instead use the Pointer properties leftButton, rightButton, middleButton and so on.

Source code: input/Pointer.js (Line 70)

circle : Phaser.Circle

A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection. The Circle size is 44px (Apples recommended "finger tip" size).

Source code: input/Pointer.js (Line 333)

clientX : number

The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).

Source code: input/Pointer.js (Line 181)

clientY : number

The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).

Source code: input/Pointer.js (Line 186)

dirty : boolean

A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not.

Source code: input/Pointer.js (Line 311)

[readonly] duration : number

How long the Pointer has been depressed on the touchscreen or any of the mouse buttons have been held down. If not currently down it returns -1. If you need to test a specific mouse or pen button then access the buttons directly, i.e. Pointer.rightButton.duration.

Source code: input/Pointer.js (Line 1150)

eraserButton : Phaser.DeviceButton

If this Pointer is a Pen / Stylus then you can access its eraser button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Please see the DeviceButton docs for details on browser button limitations.

Source code: input/Pointer.js (Line 146)

exists : boolean

A Pointer object that exists is allowed to be checked for physics collisions and overlaps.

Default Value
  • true
Source code: input/Pointer.js (Line 38)

forwardButton : Phaser.DeviceButton

If this Pointer is a Mouse or Pen / Stylus then you can access its X2 (forward) button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Please see the DeviceButton docs for details on browser button limitations.

Source code: input/Pointer.js (Line 133)

game : Phaser.Game

A reference to the currently running game.

Source code: input/Pointer.js (Line 21)

id : number

The ID of the Pointer object within the game. Each game can have up to 10 active pointers.

Source code: input/Pointer.js (Line 26)

identifier : number

The identifier property of the Pointer as set by the DOM event when this Pointer is started.

Source code: input/Pointer.js (Line 44)

isDown : boolean

If the Pointer is touching the touchscreen, or any mouse or pen button is held down, isDown is set to true. If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isDown.

Source code: input/Pointer.js (Line 255)

isMouse : boolean

If the Pointer is a mouse or pen / stylus this is true, otherwise false.

Source code: input/Pointer.js (Line 247)

isUp : boolean

If the Pointer is not touching the touchscreen, or all mouse or pen buttons are up, isUp is set to true. If you need to check a specific mouse or pen button then use the button properties, i.e. Pointer.rightButton.isUp.

Default Value
  • true
Source code: input/Pointer.js (Line 263)

leftButton : Phaser.DeviceButton

If this Pointer is a Mouse or Pen / Stylus then you can access its left button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Source code: input/Pointer.js (Line 81)

middleButton : Phaser.DeviceButton

If this Pointer is a Mouse or Pen / Stylus then you can access its middle button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Please see the DeviceButton docs for details on browser button limitations.

Source code: input/Pointer.js (Line 94)

movementX : number

The horizontal processed relative movement of the Pointer in pixels since last event.

Source code: input/Pointer.js (Line 224)

movementY : number

The vertical processed relative movement of the Pointer in pixels since last event.

Source code: input/Pointer.js (Line 230)

msSinceLastClick : number

The number of milliseconds since the last click or touch event.

Source code: input/Pointer.js (Line 293)

pageX : number

The horizontal coordinate of the Pointer relative to whole document.

Source code: input/Pointer.js (Line 191)

pageY : number

The vertical coordinate of the Pointer relative to whole document.

Source code: input/Pointer.js (Line 196)

pointerId : number

The pointerId property of the Pointer as set by the DOM event when this Pointer is started. The browser can and will recycle this value.

Source code: input/Pointer.js (Line 50)

pointerMode : Phaser.PointerMode

The operational mode of this pointer.

Source code: input/Pointer.js (Line 55)

position : Phaser.Point

A Phaser.Point object containing the current x/y values of the pointer on the display.

Source code: input/Pointer.js (Line 316)

positionDown : Phaser.Point

A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display.

Source code: input/Pointer.js (Line 321)

positionUp : Phaser.Point

A Phaser.Point object containing the x/y values of the pointer when it was last released.

Source code: input/Pointer.js (Line 326)

previousTapTime : number

A timestamp representing when the Pointer was last tapped or clicked.

Source code: input/Pointer.js (Line 281)

rawMovementX : number

The horizontal raw relative movement of the Pointer in pixels since last event.

Source code: input/Pointer.js (Line 212)

rawMovementY : number

The vertical raw relative movement of the Pointer in pixels since last event.

Source code: input/Pointer.js (Line 218)

rightButton : Phaser.DeviceButton

If this Pointer is a Mouse or Pen / Stylus then you can access its right button directly through this property.

The DeviceButton has its own properties such as isDown, duration and methods like justReleased for more fine-grained button control.

Please see the DeviceButton docs for details on browser button limitations.

Source code: input/Pointer.js (Line 107)

screenX : number

The horizontal coordinate of the Pointer relative to the screen.

Source code: input/Pointer.js (Line 201)

screenY : number

The vertical coordinate of the Pointer relative to the screen.

Source code: input/Pointer.js (Line 206)

target :any

The target property of the Pointer as set by the DOM event when this Pointer is started.

Source code: input/Pointer.js (Line 61)

targetObject :any

The Game Object this Pointer is currently over / touching / dragging.

Source code: input/Pointer.js (Line 299)

timeDown : number

A timestamp representing when the Pointer first touched the touchscreen.

Source code: input/Pointer.js (Line 269)

timeUp : number

A timestamp representing when the Pointer left the touchscreen.

Source code: input/Pointer.js (Line 275)

totalTouches : number

The total number of times this Pointer has been touched to the touchscreen.

Source code: input/Pointer.js (Line 287)

[readonly] type : number

The const type of this object.

Source code: input/Pointer.js (Line 32)

withinGame : boolean

true if the Pointer is over the game canvas, otherwise false.

Source code: input/Pointer.js (Line 176)

[readonly] worldX

Gets the X value of this Pointer in world coordinates based on the world camera.

Properties:
Name Type Description
duration number

The X value of this Pointer in world coordinates based on the world camera.

Source code: input/Pointer.js (Line 1174)

[readonly] worldY

Gets the Y value of this Pointer in world coordinates based on the world camera.

Properties:
Name Type Description
duration number

The Y value of this Pointer in world coordinates based on the world camera.

Source code: input/Pointer.js (Line 1190)

x : number

The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale.

Source code: input/Pointer.js (Line 236)

y : number

The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale.

Source code: input/Pointer.js (Line 242)

Public Methods

<internal> addClickTrampoline(name, callback, callbackContext, callbackArgs)

Add a click trampoline to this pointer.

A click trampoline is a callback that is run on the DOM 'click' event; this is primarily needed with certain browsers (ie. IE11) which restrict some actions like requestFullscreen to the DOM 'click' event and rejects it for 'pointer' and 'mouse' events.

This is used internally by the ScaleManager; click trampoline usage is uncommon. Click trampolines can only be added to pointers that are currently down.

Parameters
Name Type Description
name string

The name of the trampoline; must be unique among active trampolines in this pointer.

callback function

Callback to run/trampoline.

callbackContext object

Context of the callback.

callbackArgs Array.<object> | null

Additional callback args, if any. Supplied as an array.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source code: input/Pointer.js (Line 1031)

justPressed(duration) → {boolean}

The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return true for as long as the duration is valid. If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event.

Parameters
Name Type Argument Description
duration number <optional>

The time to check against. If none given it will use InputManager.justPressedRate.

Returns
boolean -

true if the Pointer was pressed down within the duration given.

Source code: input/Pointer.js (Line 999)

justReleased(duration) → {boolean}

The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return true for as long as the duration is valid. If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event.

Parameters
Name Type Argument Description
duration number <optional>

The time to check against. If none given it will use InputManager.justReleasedRate.

Returns
boolean -

true if the Pointer was released within the duration given.

Source code: input/Pointer.js (Line 1015)

leave(event)

Called when the Pointer leaves the target area.

Parameters
Name Type Description
event MouseEvent | PointerEvent | TouchEvent

The event passed up from the input handler.

Source code: input/Pointer.js (Line 903)

move(event, fromClick)

Called when the Pointer is moved.

Parameters
Name Type Argument Default Description
event MouseEvent | PointerEvent | TouchEvent

The event passed up from the input handler.

fromClick boolean <optional>
false

Was this called from the click event?

Source code: input/Pointer.js (Line 696)

<internal> processInteractiveObjects(fromClick) → {boolean}

Process all interactive objects to find out which ones were updated in the recent Pointer move.

Parameters
Name Type Argument Default Description
fromClick boolean <optional>
false

Was this called from the click event?

Returns
boolean -

True if this method processes an object (i.e. a Sprite becomes the Pointers currentTarget), otherwise false.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source code: input/Pointer.js (Line 793)

reset()

Resets the Pointer properties. Called by InputManager.reset when you perform a State change.

Source code: input/Pointer.js (Line 1105)

<internal> resetButtons()

Resets the states of all the button booleans.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source code: input/Pointer.js (Line 405)

resetMovement()

Resets the movementX and movementY properties. Use in your update handler after retrieving the values.

Source code: input/Pointer.js (Line 1135)

start(event)

Called when the Pointer is pressed onto the touchscreen.

Parameters
Name Type Description
event any

The DOM event from the browser.

Source code: input/Pointer.js (Line 574)

stop(event)

Called when the Pointer leaves the touchscreen.

Parameters
Name Type Description
event MouseEvent | PointerEvent | TouchEvent

The event passed up from the input handler.

Source code: input/Pointer.js (Line 916)

update()

Called by the Input Manager.

Source code: input/Pointer.js (Line 644)

<internal> updateButtons(event)

Called when the event.buttons property changes from zero. Contains a button bitmask.

Parameters
Name Type Description
event MouseEvent

The DOM event.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source code: input/Pointer.js (Line 516)