State
Entity → ceramic.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:
- Extend this class
- Override enter(), update(), and/or exit() methods
- 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";
}
}
}
See: StateMachine, StateMachineBase
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.
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 |