Skip to main content
Version: Phaser v4.0.0

Axis

Represents a single axis on a Gamepad controller, such as one direction of an analog stick. Each axis has a value property ranging from -1 to 1 (with 0 as dead center), and a configurable threshold below which the value is treated as zero by getValue(). Axis objects are created automatically by the Gamepad as they are needed.

Constructor

new Axis(pad, index)

Parameters

nametypeoptionaldescription
padPhaser.Input.Gamepad.GamepadNoA reference to the Gamepad that this Axis belongs to.
indexnumberNoThe index of this Axis.

Scope: static

Source: src/input/gamepad/Axis.js#L9
Since: 3.0.0

Public Members

events

events: Phaser.Events.EventEmitter

Description:

An event emitter to use to emit the axis events.

Source: src/input/gamepad/Axis.js#L39
Since: 3.0.0


index

index: number

Description:

The index of this Axis.

Source: src/input/gamepad/Axis.js#L48
Since: 3.0.0


pad

pad: Phaser.Input.Gamepad.Gamepad

Description:

A reference to the Gamepad that this Axis belongs to.

Source: src/input/gamepad/Axis.js#L30
Since: 3.0.0


threshold

threshold: number

Description:

Movement tolerance threshold below which axis values are ignored in getValue.

Source: src/input/gamepad/Axis.js#L68
Since: 3.0.0


value

value: number

Description:

The raw axis value, between -1 and 1 with 0 being dead center. Use the method getValue to get a normalized value with the threshold applied.

Source: src/input/gamepad/Axis.js#L57
Since: 3.0.0


Public Methods

destroy

<instance> destroy()

Description:

Destroys this Axis instance and releases external references it holds.

Source: src/input/gamepad/Axis.js#L109
Since: 3.10.0


getValue

<instance> getValue()

Description:

Returns the axis value after applying the dead zone threshold. If the absolute value of the axis is less than threshold, zero is returned instead, preventing minor stick drift from registering as intentional input. Otherwise the raw value is returned.

Returns: number - The axis value, adjusted for the movement threshold.

Source: src/input/gamepad/Axis.js#L94
Since: 3.0.0