FlixelActionDigital
View sourceclass
org.flixelgdx.input.action.FlixelActionDigital
Boolean action: any FlixelDigitalBinding that evaluates true, OR optional Steam digital for the same FlixelActionDigital.getName(), makes FlixelActionDigital.pressed() true for this frame.
Setup
Add bindings via FlixelActionDigital.addBinding(String, FlixelDigitalBinding) during construction or loading (not each frame). Multiple bindings are OR'd: a jump action might accept Space, gamepad A, and a touch region, each under its own named slot.
Reading in gameplay
- FlixelActionDigital.pressed() while a key is held (sustains, movement gates).
- FlixelActionDigital.justPressed() for a single-frame edge (tap notes, menu confirm).
- FlixelActionDigital.justReleased() when the player releases after a hold.
- FlixelActionDigital.held() for hold-repeating navigation: fires on the initial press, then fires again after FlixelAction.getHoldDelay() seconds, then every FlixelAction.getHoldInterval() seconds while held. Replaces a manual
justPressed()check when autorepeat is needed.
State is refreshed in FlixelActionSet.update(float) (via FlixelActionSets.update(float)). FlixelActionSet.endFrame() (via FlixelActionSets.endFrameAll()) runs after FlixelGame.render() finalizes keys and mouse, matching their justPressed timing.
Optional callback
FlixelAction.callback runs on the press edge when assigned; prefer a single static Runnable to avoid allocating lambdas in hot paths.
Constructors
FlixelActionDigital(String)
Methods
clearBindings()
Removes all bindings from this action, including any registered under named slots.
Use this before re-populating bindings from scratch, or to leave an action with no active sources (it will never fire until at least one binding is added again).
addBinding(String, FlixelDigitalBinding)
Adds a binding under a named slot (allocation-free after this call).
If a binding is already registered under slot, it is removed and replaced. This makes named slots the natural model for a rebinding screen: one slot per device type, replaced in-place when the player picks a new key.
jump.addBinding("keyboard", FlixelDigitalBinding.key(FlixelKey.SPACE));
jump.addBinding("gamepad", FlixelDigitalBinding.gamepadButton(0, FlixelGamepadButton.A));
// Player rebinds the keyboard slot at runtime.
jump.addBinding("keyboard", FlixelDigitalBinding.key(newKey));
Parameters:
| Name | Description |
|---|---|
slot | Non-null, non-empty identifier for this binding (for example "keyboard"). |
binding | Non-null binding. |
removeBinding(String)
Removes the binding registered under the given slot name.
Parameters:
| Name | Description |
|---|---|
slot | Slot name passed to FlixelActionDigital.addBinding(String, FlixelDigitalBinding). |
Returns: true if a binding was found and removed, false if the slot was unknown.
getBinding(String)
Returns the binding registered under the given slot name, or null if the slot is unknown.
Parameters:
| Name | Description |
|---|---|
slot | Slot name passed to FlixelActionDigital.addBinding(String, FlixelDigitalBinding). |
Returns: The registered binding, or null if no binding is registered under that slot.
removeBinding(FlixelDigitalBinding)
Removes a specific binding by reference identity.
If the binding was added via FlixelActionDigital.addBinding(String, FlixelDigitalBinding), its slot entry is also cleared.
Parameters:
| Name | Description |
|---|---|
binding | The exact binding instance to remove. |
Returns: true if the binding was found and removed.
pressed()
justPressed()
justReleased()
held()
Returns true on the initial press and again on each hold-repeat tick.
Fires immediately on the frame the button is first pressed (same as FlixelActionDigital.justPressed()), then fires again after FlixelAction.getHoldDelay() seconds if the button is still held, and continues firing every FlixelAction.getHoldInterval() seconds after that. Releasing the button resets the timer so the next press starts fresh.
Use this instead of FlixelActionDigital.justPressed() anywhere a held button should keep triggering, such as menu scrolling, cursor movement, or incrementing a value:
if (controls.uiDown.held()) scrollMenu();
Returns: true on the initial press frame and on each repeat tick.