Analog actions are events with continuous (floating-point) values, and up to two axes (x,y). This is for events like "move" and "accelerate" where the event is not simply on or off.

FlxActions let you attach multiple inputs to a single in-game action, so "move" could be performed by a gamepad joystick, a mouse movement, etc.

Available since

4.6.0

.

Constructor

@:value({ Name : "" })new(Name:String = "", ?Callback:FlxActionAnalog ‑> Void)

Create a new analog action

Parameters:

Name

name of the action

Callback

function to call when this action occurs

Variables

read onlyx:Float

X axis value, or the value of a single-axis analog input.

read onlyy:Float

Y axis value. (If action only has single-axis input this is always == 0)

callback:FlxActionAnalog ‑> Void

Function to call when this action occurs

Methods

add(input:FlxActionInputAnalog):FlxActionAnalog

Add an analog input that will trigger this action

@:value({ GamepadID : FlxInputDeviceID.FIRST_ACTIVE, Axis : EITHER })addGamepad(InputID:FlxGamepadInputID, Trigger:FlxAnalogState, Axis:FlxAnalogAxis = EITHER, GamepadID:Int = FlxInputDeviceID.FIRST_ACTIVE):FlxActionAnalog

Add gamepad action input for analog (trigger, joystick, touchpad, etc) events

Parameters:

InputID

"universal" gamepad input ID (LEFT_TRIGGER, RIGHT_ANALOG_STICK, TILT_PITCH, etc)

Trigger

What state triggers this action (MOVED, JUST_MOVED, STOPPED, JUST_STOPPED)

Axis

which axes to monitor for triggering: X, Y, EITHER, or BOTH

GamepadID

specific gamepad ID, or FlxInputDeviceID.FIRST_ACTIVE / ALL

Returns:

This action

@:value({ InvertX : false, InvertY : false, DeadZone : 0.1, PixelsPerUnit : 10, Axis : FlxAnalogAxis.EITHER })addMouseClickAndDragMotion(ButtonID:FlxMouseButtonID, Trigger:FlxAnalogState, Axis:FlxAnalogAxis = FlxAnalogAxis.EITHER, PixelsPerUnit:Int = 10, DeadZone:Float = 0.1, InvertY:Bool = false, InvertX:Bool = false):FlxActionAnalog

Add mouse input -- same as mouse motion, but requires a particular mouse button to be PRESSED Very useful for e.g. panning a map or canvas around

Parameters:

ButtonID

Button identifier (FlxMouseButtonID.LEFT / MIDDLE / RIGHT)

Trigger

What state triggers this action (MOVED, JUST_MOVED, STOPPED, JUST_STOPPED)

Axis

which axes to monitor for triggering: X, Y, EITHER, or BOTH

PixelsPerUnit

How many pixels of movement = 1.0 in analog motion (lower: more sensitive, higher: less sensitive)

DeadZone

Minimum analog value before motion will be reported

InvertY

Invert the Y axis

InvertX

Invert the X axis

Returns:

This action

@:value({ InvertX : false, InvertY : false, DeadZone : 0.1, PixelsPerUnit : 10, Axis : EITHER })addMouseMotion(Trigger:FlxAnalogState, Axis:FlxAnalogAxis = EITHER, PixelsPerUnit:Int = 10, DeadZone:Float = 0.1, InvertY:Bool = false, InvertX:Bool = false):FlxActionAnalog

Add mouse input -- X/Y is the RELATIVE motion of the mouse since the last frame

Parameters:

Trigger

What state triggers this action (MOVED, JUST_MOVED, STOPPED, JUST_STOPPED)

Axis

which axes to monitor for triggering: X, Y, EITHER, or BOTH

PixelsPerUnit

How many pixels of movement = 1.0 in analog motion (lower: more sensitive, higher: less sensitive)

DeadZone

Minimum analog value before motion will be reported

InvertY

Invert the Y axis

InvertX

Invert the X axis

Returns:

This action

@:value({ Axis : EITHER })addMousePosition(Trigger:FlxAnalogState, Axis:FlxAnalogAxis = EITHER):FlxActionAnalog

Add mouse input -- X/Y is the mouse's absolute screen position

Parameters:

Trigger

What state triggers this action (MOVED, JUST_MOVED, STOPPED, JUST_STOPPED)

Axis

which axes to monitor for triggering: X, Y, EITHER, or BOTH

Returns:

This action

Inherited Variables

Defined by FlxAction

inputs:Array<FlxActionInput>

The inputs attached to this action

read onlyname:String

The name of the action, "jump", "fire", "move", etc.

@:value(false)read onlysteamOriginsChanged:Bool = false

Whether the steam controller inputs for this action have changed since the last time origins were polled. Always false if steam isn't active

@:value(false)read onlytriggered:Bool = false

If true, this action has just been triggered

read onlytype:FlxInputType

Digital or Analog

Inherited Methods

Defined by FlxAction

@:value({ Destroy : false })remove(Input:FlxActionInput, Destroy:Bool = false):Void

@:value({ Destroy : true })removeAll(Destroy:Bool = true):Void