A digital action is a binary on/off event like "jump" or "fire". FlxActions let you attach multiple inputs to a single in-game action, so "jump" could be performed by a keyboard press, a mouse click, or a gamepad button press.

Available since

4.6.0

.

Constructor

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

Create a new digital action

Parameters:

Name

name of the action

Callback

function to call when this action occurs

Variables

callback:FlxActionDigital ‑> Void

Function to call when this action occurs

Methods

add(input:FlxActionInputDigital):FlxActionDigital

Add a digital input (any kind) that will trigger this action

Parameters:

input

Returns:

This action

@:value({ GamepadID : FlxInputDeviceID.FIRST_ACTIVE })addGamepad(InputID:FlxGamepadInputID, Trigger:FlxInputState, GamepadID:Int = FlxInputDeviceID.FIRST_ACTIVE):FlxActionDigital

Add a gamepad action input for digital (button-like) events

Parameters:

InputID

"universal" gamepad input ID (A, X, DPAD_LEFT, etc)

Trigger

What state triggers this action (PRESSED, JUST_PRESSED, RELEASED, JUST_RELEASED)

GamepadID

specific gamepad ID, or FlxInputDeviceID.ALL / FIRST_ACTIVE

Returns:

This action

addInput(Input:IFlxInput, Trigger:FlxInputState):FlxActionDigital

Add a generic IFlxInput action input

WARNING: IFlxInput objects are often member variables of some other object that is often destructed at the end of a state. If you don't destroy() this input (or the action you assign it to), the IFlxInput reference will persist forever even after its parent object has been destroyed!

Parameters:

Input

A generic IFlxInput object (ex: FlxButton.input)

Trigger

Trigger What state triggers this action (PRESSED, JUST_PRESSED, RELEASED, JUST_RELEASED)

Returns:

This action

addKey(Key:FlxKey, Trigger:FlxInputState):FlxActionDigital

Add a keyboard action input

Parameters:

Key

Key identifier (FlxKey.SPACE, FlxKey.Z, etc)

Trigger

What state triggers this action (PRESSED, JUST_PRESSED, RELEASED, JUST_RELEASED)

Returns:

This action

addMouse(ButtonID:FlxMouseButtonID, Trigger:FlxInputState):FlxActionDigital

Mouse button action input

Parameters:

ButtonID

Button identifier (FlxMouseButtonID.LEFT / MIDDLE / RIGHT)

Trigger

What state triggers this action (PRESSED, JUST_PRESSED, RELEASED, JUST_RELEASED)

Returns:

This action

addMouseWheel(Positive:Bool, Trigger:FlxInputState):FlxActionDigital

Action for mouse wheel events

Parameters:

Positive

True: respond to mouse wheel values > 0; False: respond to mouse wheel values < 0

Trigger

What state triggers this action (PRESSED, JUST_PRESSED, RELEASED, JUST_RELEASED)

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

update():Void

Check input states & fire callbacks if anything is triggered