onEvent()
ecs.defineState(name).onEvent(event, nextState, args)
Description
Trigger a transition to the next state when an event is received.
Parameters
Property | Type | Description |
---|---|---|
event | string | the event to listen for |
nextState | string or State | the next state to transition to. You can pass another state returned by defineState or just the state name |
args | EventObject | optional arguments for the event |
EventObject
Property | Type | Description |
---|---|---|
target (optional) | eid | the entity you want this trigger to change state for |
beforeTransition (optional) | (event) => boolean | a function that run before the transition, if the result is truthy then the transition will terminate and the state will not change |