pub trait State<S> {
// Provided methods
fn on_start(&mut self, _state_data: &mut S) { ... }
fn on_stop(&mut self, _state_data: &mut S) { ... }
fn on_pause(&mut self, _state_data: &mut S) { ... }
fn on_resume(&mut self, _state_data: &mut S) { ... }
fn update(&mut self, _state_data: &mut S) -> StateTransition<S> { ... }
}Expand description
Trait that states must implement.
§Generics
- S: State data, the data that is sent to states for them to do their operations.
Provided Methods§
Sourcefn on_start(&mut self, _state_data: &mut S)
fn on_start(&mut self, _state_data: &mut S)
Called when the state is first inserted on the stack.
Sourcefn on_pause(&mut self, _state_data: &mut S)
fn on_pause(&mut self, _state_data: &mut S)
Called when a state is pushed over this one in the stack.
Sourcefn on_resume(&mut self, _state_data: &mut S)
fn on_resume(&mut self, _state_data: &mut S)
Called when the state just on top of this one in the stack is popped.
Sourcefn update(&mut self, _state_data: &mut S) -> StateTransition<S>
fn update(&mut self, _state_data: &mut S) -> StateTransition<S>
Executed on every frame immediately, as fast as the engine will allow. If you need to execute logic at a predictable interval (for example, a physics engine) it is suggested to use the state data information to determine when to run such fixed timed logic.