State

Entityceramic.State (Class)

Base class for states in a state machine.

State represents a single state within a StateMachine. Each state has lifecycle methods that are called when entering, updating, and exiting the state. States can access their parent state machine to trigger transitions or access shared data.

To create a state:

  1. Extend this class
  2. Override enter(), update(), and/or exit() methods
  3. Add the state to a StateMachine

Example usage:

class IdleState extends State {
    override function enter() {
        trace("Entering idle state");
    }
    override function update(delta:Float) {
        if (playerInput.isMoving) {
            machine.state = "walking";
        }
    }
}

Instance Members

machine: StateMachine<Any>

The state machine that owns this state. Set automatically when the state is added to a machine.


enter(): Void

Called when entering this state. Override this method to perform initialization when the state becomes active.


update(delta: Float): Void

Called every frame while this state is active. Override this method to implement state behavior and transitions.

Name Type Description
delta Float Time elapsed since last update in seconds

exit(): Void

Called when exiting this state. Override this method to perform cleanup when transitioning to another state.


new(): Void

Metadata

Name Parameters
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:allow ceramic.StateMachineImpl