Namespace: Input

Phaser. Input

Classes

InputManager
InputPlugin
Pointer

Namespaces

Gamepad
Keyboard
Mouse
Touch

Members


<static> MOUSE_DOWN :integer

The mouse pointer is being held down.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 9)

<static> MOUSE_MOVE :integer

The mouse pointer is being moved.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 18)

<static> MOUSE_UP :integer

The mouse pointer is released.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 27)

<static> POINTER_LOCK_CHANGE :integer

The pointer lock has changed.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 72)

<static> TOUCH_CANCEL :integer

A touch pointer has been been cancelled by the browser.

Type:
  • integer
Since: 3.15.0
Source: src/input/const.js (Line 63)

<static> TOUCH_END :integer

A touch pointer has been started.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 54)

<static> TOUCH_MOVE :integer

A touch pointer has been started.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 45)

<static> TOUCH_START :integer

A touch pointer has been started.

Type:
  • integer
Since: 3.10.0
Source: src/input/const.js (Line 36)

Methods


<static> CreateInteractiveObject(gameObject, hitArea, hitAreaCallback)

Creates a new Interactive Object.

This is called automatically by the Input Manager when you enable a Game Object for input.

The resulting Interactive Object is mapped to the Game Object's input property.

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

The Game Object to which this Interactive Object is bound.

hitArea any

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

hitAreaCallback HitAreaCallback

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

Since: 3.0.0
Source: src/input/CreateInteractiveObject.js (Line 39)
Returns:

The new Interactive Object.

Type
Phaser.Input.InteractiveObject

<static> CreatePixelPerfectHandler(textureManager, alphaTolerance)

Creates a new Pixel Perfect Handler function.

Access via InputPlugin.makePixelPerfect rather than calling it directly.

Parameters:
Name Type Description
textureManager Phaser.Textures.TextureManager

A reference to the Texture Manager.

alphaTolerance integer

The alpha level that the pixel should be above to be included as a successful interaction.

Since: 3.10.0
Source: src/input/CreatePixelPerfectHandler.js (Line 7)
Returns:

The new Pixel Perfect Handler function.

Type
function

Type Definitions


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 function <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 integer <optional>
1

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

Source: src/input/InputPlugin.js (Line 1496)

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?

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 HitAreaCallback

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

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 that the Pointer started dragging this Interactive Object from.

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

Source: src/input/CreateInteractiveObject.js (Line 18)