Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: StateComponent

[16:7] extends: Component

Wraps FXGL's StateComponent (com.almasb.fxgl.entity.state.StateComponent), the per-entity FSM container that tracks the current EntityState and provides transitions. Attach to an entity then call changeState / changeStateAllowReentry / changeStateToIdle.

Methods

  • StateComponent (InitialState = null)

    Creates a StateComponent starting in the default IDLE state.

  • adopt (object Ajo)

    Wraps an existing StateComponent AussomJavaObject.

  • getCurrentState ()

    Returns the current state as an EntityState wrapper.

  • currentStateProperty ()

    Returns the current-state ReadOnlyObjectProperty for binding.

  • isIdle ()

    Returns whether the current state is IDLE.

  • changeStateToIdle ()

    Transitions to the IDLE state.

  • changeState (object StateObj)

    Transitions to a new state. No-op if already in that state.

  • changeStateAllowReentry (object StateObj)

    Transitions to a state and re-fires onEnteredFrom even when already in that state.

  • isIn (list States)

    Returns true when the current state is among the supplied states.

    • @p States is a list of EntityState wrappers / AJOs.
    • @r A bool.