Namespace: Input

Phaser.Types. Input

Namespaces

Gamepad
Keyboard

Type Definitions


EventData

A Phaser Input Event Data object.

This object is passed to the registered event listeners and allows you to stop any further propagation.

Type:
  • object
Properties:
Name Type Argument Default Description
cancelled boolean <optional>
false

The cancelled state of this Event.

stopPropagation function

Call this method to stop this event from passing any further down the event chain.

Since: 3.15.1
Source: src/input/typedefs/EventData.js (Line 7)

HitAreaCallback(hitArea, x, y, gameObject)

Parameters:
Name Type Description
hitArea any

The hit area object.

x number

The translated x coordinate of the hit test event.

y number

The translated y coordinate of the hit test event.

gameObject Phaser.GameObjects.GameObject

The Game Object that invoked the hit test.

Since: 3.0.0
Source: src/input/typedefs/HitAreaCallback.js (Line 1)
Returns:

true if the coordinates fall within the space of the hitArea, otherwise false.

Type
boolean

InputConfiguration

Type:
  • object
Properties:
Name Type Argument Default Description
hitArea any <optional>

The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame.

hitAreaCallback Phaser.Types.Input.HitAreaCallback <optional>

The callback that determines if the pointer is within the Hit Area shape or not.

draggable boolean <optional>
false

If true the Interactive Object will be set to be draggable and emit drag events.

dropZone boolean <optional>
false

If true the Interactive Object will be set to be a drop zone for draggable objects.

useHandCursor boolean <optional>
false

If true the Interactive Object will set the pointer hand cursor when a pointer is over it. This is a short-cut for setting cursor: 'pointer'.

cursor string <optional>

The CSS string to be used when the cursor is over this Interactive Object.

pixelPerfect boolean <optional>
false

If true the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects.

alphaTolerance number <optional>
1

If pixelPerfect is set, this is the alpha tolerance threshold value used in the callback.

Since: 3.0.0
Source: src/input/typedefs/InputConfiguration.js (Line 1)

InputPluginContainer

Type:
  • object
Properties:
Name Type Argument Description
key string

The unique name of this plugin in the input plugin cache.

plugin function

The plugin to be stored. Should be the source object, not instantiated.

mapping string <optional>

If this plugin is to be injected into the Input Plugin, this is the property key map used.

Since: 3.0.0
Source: src/input/typedefs/InputPluginContainer.js (Line 1)

InteractiveObject

Type:
  • object
Properties:
Name Type Argument Description
gameObject Phaser.GameObjects.GameObject

The Game Object to which this Interactive Object is bound.

enabled boolean

Is this Interactive Object currently enabled for input events?

alwaysEnabled boolean

An Interactive Object that is 'always enabled' will receive input even if the parent object is invisible or won't render.

draggable boolean

Is this Interactive Object draggable? Enable with InputPlugin.setDraggable.

dropZone boolean

Is this Interactive Object a drag-targets drop zone? Set when the object is created.

cursor boolean | string

Should this Interactive Object change the cursor (via css) when over? (desktop only)

target Phaser.GameObjects.GameObject <nullable>

An optional drop target for a draggable Interactive Object.

camera Phaser.Cameras.Scene2D.Camera

The most recent Camera to be tested against this Interactive Object.

hitArea any

The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle.

hitAreaCallback Phaser.Types.Input.HitAreaCallback

The 'contains' check callback that the hit area shape will use for all hit tests.

hitAreaDebug Phaser.GameObjects.Shape

If this Interactive Object has been enabled for debug, via InputPlugin.enableDebug then this property holds its debug shape.

customHitArea boolean

Was the hitArea for this Interactive Object created based on texture size (false), or a custom shape? (true)

localX number

The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.

localY number

The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.

dragState 0 | 1 | 2

The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged.

dragStartX number

The x coordinate of the Game Object that owns this Interactive Object when the drag started.

dragStartY number

The y coordinate of the Game Object that owns this Interactive Object when the drag started.

dragStartXGlobal number

The x coordinate that the Pointer started dragging this Interactive Object from.

dragStartYGlobal number

The y coordinate that the Pointer started dragging this Interactive Object from.

dragX number

The x coordinate that this Interactive Object is currently being dragged to.

dragY number

The y coordinate that this Interactive Object is currently being dragged to.

Since: 3.0.0
Source: src/input/typedefs/InteractiveObject.js (Line 1)