new Pointer(game, id)
Phaser - Pointer constructor.
Parameters:
Name | Type | 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. |
- Source:
Members
-
active
-
- Default Value:
- false
- Source:
Properties:
Name Type Description active
boolean An active pointer is one that is currently pressed down on the display. A Mouse is always active.
-
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:
Properties:
Name Type Description circle
Phaser.Circle -
clientX
-
- Source:
Properties:
Name Type Description clientX
number The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset.
-
clientY
-
- Source:
Properties:
Name Type Description clientY
number The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset.
-
<readonly> duration
-
How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
- Source:
Properties:
Name Type Description duration
number How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running game.
-
id
-
- Source:
Properties:
Name Type Description id
number The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
-
isDown
-
- Default Value:
- false
- Source:
Properties:
Name Type Description isDown
boolean If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
-
isMouse
-
- Default Value:
- false
- Source:
Properties:
Name Type Description isMouse
boolean If the Pointer is a mouse this is true, otherwise false.
-
isUp
-
- Default Value:
- true
- Source:
Properties:
Name Type Description isUp
boolean If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.
-
msSinceLastClick
-
- Source:
Properties:
Name Type Description msSinceLastClick
number The number of miliseconds since the last click.
-
pageX
-
- Source:
Properties:
Name Type Description pageX
number The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset.
-
pageY
-
- Source:
Properties:
Name Type Description pageY
number The vertical coordinate of point relative to the viewport in pixels, including any scroll offset.
-
position
-
- Source:
Properties:
Name Type Description position
Phaser.Point A Phaser.Point object containing the current x/y values of the pointer on the display.
-
positionDown
-
- Source:
Properties:
Name Type Description 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.
-
positionUp
-
- Source:
Properties:
Name Type Description positionUp
Phaser.Point A Phaser.Point object containing the x/y values of the pointer when it was last released.
-
previousTapTime
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description previousTapTime
number A timestamp representing when the Pointer was last tapped or clicked.
-
screenX
-
- Source:
Properties:
Name Type Description screenX
number The horizontal coordinate of point relative to the screen in pixels.
-
screenY
-
- Source:
Properties:
Name Type Description screenY
number The vertical coordinate of point relative to the screen in pixels.
-
targetObject
-
- Default Value:
- null
- Source:
Properties:
Name Type Description targetObject
any The Game Object this Pointer is currently over / touching / dragging.
-
timeDown
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description timeDown
number A timestamp representing when the Pointer first touched the touchscreen.
-
timeUp
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description timeUp
number A timestamp representing when the Pointer left the touchscreen.
-
totalTouches
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description totalTouches
number The total number of times this Pointer has been touched to the touchscreen.
-
withinGame
-
- Source:
Properties:
Name Type Description withinGame
boolean true if the Pointer is within the game area, otherwise false.
-
<readonly> worldX
-
Gets the X value of this Pointer in world coordinates based on the world camera.
- Source:
Properties:
Name Type Description duration
number The X value of this Pointer in world coordinates based on the world camera.
-
<readonly> worldY
-
Gets the Y value of this Pointer in world coordinates based on the world camera.
- Source:
Properties:
Name Type Description duration
number The Y value of this Pointer in world coordinates based on the world camera.
-
x
-
- Source:
Properties:
Name Type Description x
number The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
-
y
-
- Source:
Properties:
Name Type Description y
number The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
Methods
-
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.
- Source:
Returns:
true if the Pointer was pressed down within the duration given.
- Type
- boolean
-
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.
- Source:
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:
-
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:
-
reset()
-
Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
- Source:
-
start(event)
-
Called when the Pointer is pressed onto the touchscreen.
Parameters:
Name Type Description event
Any - Source:
-
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:
-
update()
-
Called by the Input Manager.
- Source: