Constructor
(abstract) new State(nameopt)
Creates a new State object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
"undefined" | Unique (descriptive) identifier. |
- Source:
Members
(readonly) name :string
Represents a unique ID for the current state.
Type:
- string
- Source:
(readonly) owner :Object
Reference to the object that is in the current state. This value is constant
and cannot change during the existence of the state.
Type:
- Object
- Source:
Methods
dispose() → {undefined}
Called when the state machine destroys the current state object. Override
and write your own dispose routine. This is necessary if the state
creates its own object instances. Incorrect or inadequate deallocation
results in memory leaks.
- Source:
Returns:
- Type
- undefined
init() → {undefined}
Called when the state is initiated by the state machine. Override this
method if the state, for example, needs to create objects or execute logic
as soon as the state is created.
- Source:
Returns:
- Type
- undefined
onEnter(state) → {undefined}
Is activated when the state machine selects the current state.
Parameters:
Name | Type | Description |
---|---|---|
state |
rune.state.State | The old state. |
- Source:
Returns:
- Type
- undefined
onExit(state) → {undefined}
Is activated when the state machine switches to another state.
Parameters:
Name | Type | Description |
---|---|---|
state |
rune.state.State | The new state. |
- Source:
Returns:
- Type
- undefined
render() → {undefined}
It is unusual for a state to need its own rendering code, but this is
possible by overriding this method.
- Source:
Returns:
- Type
- undefined
update(step) → {undefined}
Called for each tick (frame). Override and write custom logic for the
current State object, ie the program code that is executed when the owner
object is in this state.
Parameters:
Name | Type | Description |
---|---|---|
step |
number | Current time step. |
- Source:
Returns:
- Type
- undefined