Zum Hauptinhalt springen

onEvent()

ecs.defineState(name).onEvent(event, nextState, args)

Description

Trigger a transition to the next state when an event is received.

Parameters

PropertyTypeDescription
eventstringthe event to listen for
nextStatestring or Statethe next state to transition to. You can pass another state returned by defineState or just the state name
argsEventObjectoptional arguments for the event

EventObject

PropertyTypeDescription
target (optional)eidthe entity you want this trigger to change state for
beforeTransition (optional)(event) => booleana function that run before the transition, if the result is truthy then the transition will terminate and the state will not change