Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: StateMachine

[16:7] extends: FxObj

Wraps FXGL's StateMachine (com.almasb.fxgl.core.fsm.StateMachine), a generic FSM container with a single parent state plus a queue of optional substates. Pair with the State wrapper (or any AussomState-implementing AJO) to drive gameplay phases, AI, menu transitions.

Methods

  • StateMachine (object InitialState)

    Creates a new StateMachine with the given initial state.

    • @p InitialState is a State wrapper (or AJO implementing State).
  • getParentState ()

    Returns the current parent state as an AJO.

  • getCurrentState ()

    Returns the current state (substate if any, else parent).

  • getActiveStates ()

    Returns the active states as an AussomJavaObject around a CopyOnWriteArrayList.

  • isInHierarchy (object StateObj)

    Returns true when State is in the parent-or-substate hierarchy.

  • changeState (object NewState)

    Transitions to the new state. If newState.isSubState the state is pushed; otherwise it replaces the parent state.

  • popSubState ()

    Pops the topmost substate. Returns true when a substate was popped, false when no substate was active.

  • runOnActiveStates (callback Action)

    Calls Action(state) for every currently-active state.

    • @p Action is a callback (stateAjo) -> void.
    • @r this object