Class: Pointer

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 CONTACT.

Source:
src/input/Pointer.js line 16

Members

<static, constant> 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.

Type:
  • number
Source:
src/input/Pointer.js line 398

<static, constant> ERASER_BUTTON : number

The Eraser pen button on PointerEvent supported devices only.

Type:
  • number
Source:
src/input/Pointer.js line 413

<static, constant> 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.

Type:
  • number
Source:
src/input/Pointer.js line 406

<static, constant> LEFT_BUTTON : number

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

Type:
  • number
Source:
src/input/Pointer.js line 376

<static, constant> MIDDLE_BUTTON : number

The Middle Mouse button.

Type:
  • number
Source:
src/input/Pointer.js line 390

<static, constant> NO_BUTTON : number

No buttons at all.

Type:
  • number
Source:
src/input/Pointer.js line 369

<static, constant> RIGHT_BUTTON : number

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

Type:
  • number
Source:
src/input/Pointer.js line 383

active : boolean

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

Type:
  • boolean
Source:
src/input/Pointer.js line 317

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.

Type:
Source:
src/input/Pointer.js line 121

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.

Type:
  • any
Source:
src/input/Pointer.js line 71

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).

Type:
Source:
src/input/Pointer.js line 345

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).

Type:
  • number
Source:
src/input/Pointer.js line 182

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).

Type:
  • number
Source:
src/input/Pointer.js line 187

dirty : boolean

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

Type:
  • boolean
Source:
src/input/Pointer.js line 323

<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.

Type:
  • number
Source:
src/input/Pointer.js line 1229

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.

Type:
Source:
src/input/Pointer.js line 147

exists : boolean

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

Type:
  • boolean
Default Value:
  • true
Source:
src/input/Pointer.js line 39

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.

Type:
Source:
src/input/Pointer.js line 134

game : Phaser.Game

A reference to the currently running game.

Type:
Source:
src/input/Pointer.js line 22

id : number

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

Type:
  • number
Source:
src/input/Pointer.js line 27

identifier : number

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

Type:
  • number
Source:
src/input/Pointer.js line 45

interactiveCandidates : array

This array is erased and re-populated every time this Pointer is updated. It contains references to all of the Game Objects that were considered as being valid for processing by this Pointer, this frame. To be valid they must have suitable a priorityID, be Input enabled, visible and actually have the Pointer over them. You can check the contents of this array in events such as onInputDown, but beware it is reset every frame.

Type:
  • array
Default Value:
  • []
Source:
src/input/Pointer.js line 311

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.

Type:
  • boolean
Source:
src/input/Pointer.js line 256

isMouse : boolean

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

Type:
  • boolean
Source:
src/input/Pointer.js line 248

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.

Type:
  • boolean
Default Value:
  • true
Source:
src/input/Pointer.js line 264

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.

Type:
Source:
src/input/Pointer.js line 82

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.

Type:
Source:
src/input/Pointer.js line 95

movementX : number

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

Type:
  • number
Source:
src/input/Pointer.js line 225

movementY : number

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

Type:
  • number
Source:
src/input/Pointer.js line 231

msSinceLastClick : number

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

Type:
  • number
Source:
src/input/Pointer.js line 294

pageX : number

The horizontal coordinate of the Pointer relative to whole document.

Type:
  • number
Source:
src/input/Pointer.js line 192

pageY : number

The vertical coordinate of the Pointer relative to whole document.

Type:
  • number
Source:
src/input/Pointer.js line 197

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.

Type:
  • number
Source:
src/input/Pointer.js line 51

pointerMode : Phaser.PointerMode

The operational mode of this pointer.

Type:
Source:
src/input/Pointer.js line 56

position : Phaser.Point

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

Type:
Source:
src/input/Pointer.js line 328

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.

Type:
Source:
src/input/Pointer.js line 333

positionUp : Phaser.Point

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

Type:
Source:
src/input/Pointer.js line 338

previousTapTime : number

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

Type:
  • number
Source:
src/input/Pointer.js line 282

rawMovementX : number

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

Type:
  • number
Source:
src/input/Pointer.js line 213

rawMovementY : number

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

Type:
  • number
Source:
src/input/Pointer.js line 219

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.

Type:
Source:
src/input/Pointer.js line 108

screenX : number

The horizontal coordinate of the Pointer relative to the screen.

Type:
  • number
Source:
src/input/Pointer.js line 202

screenY : number

The vertical coordinate of the Pointer relative to the screen.

Type:
  • number
Source:
src/input/Pointer.js line 207

target : any

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

Type:
  • any
Source:
src/input/Pointer.js line 62

targetObject : any

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

Type:
  • any
Source:
src/input/Pointer.js line 300

timeDown : number

A timestamp representing when the Pointer first touched the touchscreen.

Type:
  • number
Source:
src/input/Pointer.js line 270

timeUp : number

A timestamp representing when the Pointer left the touchscreen.

Type:
  • number
Source:
src/input/Pointer.js line 276

totalTouches : number

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

Type:
  • number
Source:
src/input/Pointer.js line 288

<readonly> type : number

The const type of this object.

Type:
  • number
Source:
src/input/Pointer.js line 33

withinGame : boolean

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

Type:
  • boolean
Source:
src/input/Pointer.js line 177

<readonly> worldX : number

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

Type:
  • number
Source:
src/input/Pointer.js line 1254

<readonly> worldY : number

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

Type:
  • number
Source:
src/input/Pointer.js line 1271

x : number

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

Type:
  • number
Source:
src/input/Pointer.js line 237

y : number

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

Type:
  • number
Source:
src/input/Pointer.js line 243

Methods

<protected> 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.

Source:
src/input/Pointer.js line 1106

justPressed( [duration])

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.

Source:
src/input/Pointer.js line 1072
Returns:

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

Type
boolean

justReleased( [duration])

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.

Source:
src/input/Pointer.js line 1089
Returns:

true if the Pointer was released within the duration given.

Type
boolean

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:
src/input/Pointer.js line 974

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:
src/input/Pointer.js line 743

<protected> processInteractiveObjects( [fromClick])

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?

Source:
src/input/Pointer.js line 835
Returns:

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

Type
boolean

reset()

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

Source:
src/input/Pointer.js line 1182

<protected> resetButtons()

Resets the states of all the button booleans.

Source:
src/input/Pointer.js line 417

resetMovement()

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

Source:
src/input/Pointer.js line 1213

start(event)

Called when the Pointer is pressed onto the touchscreen.

Parameters:
Name Type Description
event any

The DOM event from the browser.

Source:
src/input/Pointer.js line 619

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:
src/input/Pointer.js line 988

swapTarget(newTarget [, silent])

This will change the Pointer.targetObject object to be the one provided.

This allows you to have fine-grained control over which object the Pointer is targeting.

Note that even if you set a new Target here, it is still able to be replaced by any other valid target during the next Pointer update.

Parameters:
Name Type Argument Default Description
newTarget Phaser.InputHandler

The new target for this Pointer. Note this is an InputHandler, so don't pass a Sprite, instead pass sprite.input to it.

silent boolean <optional>
false

If true the new target AND the old one will NOT dispatch their onInputOver or onInputOut events.

Source:
src/input/Pointer.js line 916

update()

Called by the Input Manager.

Source:
src/input/Pointer.js line 690

<protected> updateButtons(event)

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

Parameters:
Name Type Description
event MouseEvent

The DOM event.

Source:
src/input/Pointer.js line 594

phaser-ce@2.10.6 is on GitHub and NPM

Documentation generated by JSDoc 3.5.4 on 2018-06-01 using Tomorrow.