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 activeboolean An active pointer is one that is currently pressed down on the display. A Mouse is always active.
-
button
-
- Default Value:
- null
- Source:
Properties:
Name Type Description buttonany The button property of the Pointer as set by the DOM event when this Pointer is started.
-
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 circlePhaser.Circle -
clientX
-
- Source:
Properties:
Name Type Description clientXnumber 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).
-
clientY
-
- Source:
Properties:
Name Type Description clientYnumber 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).
-
dirty
-
- Default Value:
- false
- Source:
Properties:
Name Type Description dirtyboolean A dirty pointer needs to re-poll any interactive objects it may have been over, regardless if it has moved or not.
-
<readonly> duration
-
How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
- Source:
Properties:
Name Type Description durationnumber How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
-
exists
-
- Default Value:
- true
- Source:
Properties:
Name Type Description existsboolean A Pointer object that exists is allowed to be checked for physics collisions and overlaps.
-
game
-
- Source:
Properties:
Name Type Description gamePhaser.Game A reference to the currently running game.
-
id
-
- Source:
Properties:
Name Type Description idnumber The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
-
identifier
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description identifiernumber The identifier property of the Pointer as set by the DOM event when this Pointer is started.
-
isDown
-
- Default Value:
- false
- Source:
Properties:
Name Type Description isDownboolean 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 isMouseboolean If the Pointer is a mouse this is true, otherwise false.
-
isUp
-
- Default Value:
- true
- Source:
Properties:
Name Type Description isUpboolean If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.
-
movementX
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description movementXnumber The horizontal processed relative movement of the Pointer in pixels since last event.
-
movementY
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description movementYnumber The vertical processed relative movement of the Pointer in pixels since last event.
-
msSinceLastClick
-
- Source:
Properties:
Name Type Description msSinceLastClicknumber The number of milliseconds since the last click or touch event.
-
pageX
-
- Source:
Properties:
Name Type Description pageXnumber The horizontal coordinate of the Pointer relative to whole document.
-
pageY
-
- Source:
Properties:
Name Type Description pageYnumber The vertical coordinate of the Pointer relative to whole document.
-
pointerId
-
- Default Value:
- null
- Source:
Properties:
Name Type Description pointerIdnumber 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.
-
position
-
- Source:
Properties:
Name Type Description positionPhaser.Point A Phaser.Point object containing the current x/y values of the pointer on the display.
-
positionDown
-
- Source:
Properties:
Name Type Description positionDownPhaser.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 positionUpPhaser.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 previousTapTimenumber A timestamp representing when the Pointer was last tapped or clicked.
-
rawMovementX
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description rawMovementXnumber The horizontal raw relative movement of the Pointer in pixels since last event.
-
rawMovementY
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description rawMovementYnumber The vertical raw relative movement of the Pointer in pixels since last event.
-
screenX
-
- Source:
Properties:
Name Type Description screenXnumber The horizontal coordinate of the Pointer relative to the screen.
-
screenY
-
- Source:
Properties:
Name Type Description screenYnumber The vertical coordinate of the Pointer relative to the screen.
-
target
-
- Default Value:
- null
- Source:
Properties:
Name Type Description targetany The target property of the Pointer as set by the DOM event when this Pointer is started.
-
targetObject
-
- Default Value:
- null
- Source:
Properties:
Name Type Description targetObjectany The Game Object this Pointer is currently over / touching / dragging.
-
timeDown
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description timeDownnumber A timestamp representing when the Pointer first touched the touchscreen.
-
timeUp
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description timeUpnumber A timestamp representing when the Pointer left the touchscreen.
-
totalTouches
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description totalTouchesnumber The total number of times this Pointer has been touched to the touchscreen.
-
<readonly> type
-
- Source:
Properties:
Name Type Description typenumber The const type of this object.
-
withinGame
-
- Source:
Properties:
Name Type Description withinGameboolean true if the Pointer is over the game canvas, otherwise false.
-
<readonly> worldX
-
Gets the X value of this Pointer in world coordinates based on the world camera.
- Source:
Properties:
Name Type Description durationnumber 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 durationnumber The Y value of this Pointer in world coordinates based on the world camera.
-
x
-
- Source:
Properties:
Name Type Description xnumber The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale.
-
y
-
- Source:
Properties:
Name Type Description ynumber The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale.
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
truefor 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 durationnumber <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
truefor 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 durationnumber <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 eventMouseEvent | 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 eventMouseEvent | PointerEvent | TouchEvent The event passed up from the input handler.
fromClickboolean <optional>
false Was this called from the click event?
- Source:
-
<protected> 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 fromClickboolean <optional>
false Was this called from the click event?
- Source:
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:
-
resetMovement()
-
Resets the movementX and movementY properties. Use in your update handler after retrieving the values.
- Source:
-
start(event)
-
Called when the Pointer is pressed onto the touchscreen.
Parameters:
Name Type Description eventany The DOM event from the browser.
- Source:
-
stop(event)
-
Called when the Pointer leaves the touchscreen.
Parameters:
Name Type Description eventMouseEvent | PointerEvent | TouchEvent The event passed up from the input handler.
- Source:
-
update()
-
Called by the Input Manager.
- Source: