State

Trait State 

Source
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§

Source

fn on_start(&mut self, _state_data: &mut S)

Called when the state is first inserted on the stack.

Source

fn on_stop(&mut self, _state_data: &mut S)

Called when the state is popped from the stack.

Source

fn on_pause(&mut self, _state_data: &mut S)

Called when a state is pushed over this one in the stack.

Source

fn on_resume(&mut self, _state_data: &mut S)

Called when the state just on top of this one in the stack is popped.

Source

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.

Implementors§