Trait State

Source
pub trait State: 'static {
    // Required method
    fn draw(&mut self, framebuffer: &mut Framebuffer<'_>);

    // Provided methods
    fn update(&mut self, delta_time: f64) { ... }
    fn fixed_update(&mut self, delta_time: f64) { ... }
    fn handle_event(&mut self, event: Event) { ... }
    fn transition(&mut self) -> Option<Transition> { ... }
    fn ui<'a>(&'a mut self, cx: &'a Controller) -> Box<dyn Widget + 'a> { ... }
}
Expand description

Represents a state in the game.

Required Methods§

Source

fn draw(&mut self, framebuffer: &mut Framebuffer<'_>)

Provided Methods§

Source

fn update(&mut self, delta_time: f64)

Called every frame.

Source

fn fixed_update(&mut self, delta_time: f64)

Called periodically every fixed_delta_time defined in [ContextOptions]. To start the application with different fixed_delta_time, initialize geng with [Geng::new_with()].

Source

fn handle_event(&mut self, event: Event)

Called whenever an event is registered. See Event for a full list of possible events.

Source

fn transition(&mut self) -> Option<Transition>

Called every frame. If returns Some, then a transition occurs.

Source

fn ui<'a>(&'a mut self, cx: &'a Controller) -> Box<dyn Widget + 'a>

Implementations on Foreign Types§

Source§

impl<T> State for Box<T>
where T: State + ?Sized,

Source§

fn update(&mut self, delta_time: f64)

Source§

fn fixed_update(&mut self, delta_time: f64)

Source§

fn draw(&mut self, framebuffer: &mut Framebuffer<'_>)

Source§

fn handle_event(&mut self, event: Event)

Source§

fn transition(&mut self) -> Option<Transition>

Source§

fn ui<'a>(&'a mut self, cx: &'a Controller) -> Box<dyn Widget + 'a>

Implementors§

Source§

impl State for Manager

Source§

impl State for Empty

Source§

impl State for EmptyLoadingScreen

Source§

impl<A, B> State for CombinedState<A, B>
where A: State, B: State,

Source§

impl<L, G> State for LoadingScreen<L, G>
where L: ProgressScreen, G: State,