Trait geng::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,