pub trait Game: Sized + 'static {
// Required methods
fn init(ctx: &mut Context) -> Result<Self, Error>;
fn update(&mut self, ctx: &mut Context, dt: f32);
fn render(&mut self, ctx: &mut Context, frame: &mut Frame);
// Provided methods
fn event(&mut self, _ctx: &mut Context, _event: &GameEvent) { ... }
fn raw_window_event(
&mut self,
_ctx: &mut Context,
_event: &WindowEvent,
) -> bool { ... }
fn shutdown(&mut self, _ctx: &mut Context) { ... }
}Required Methods§
fn init(ctx: &mut Context) -> Result<Self, Error>
fn update(&mut self, ctx: &mut Context, dt: f32)
fn render(&mut self, ctx: &mut Context, frame: &mut Frame)
Provided Methods§
fn event(&mut self, _ctx: &mut Context, _event: &GameEvent)
Sourcefn raw_window_event(&mut self, _ctx: &mut Context, _event: &WindowEvent) -> bool
fn raw_window_event(&mut self, _ctx: &mut Context, _event: &WindowEvent) -> bool
Raw winit window-event hook. Return true to mark the event consumed so it is not
forwarded to the toolkit’s game_toolkit_input::Input state. Use this for egui or other
overlays that need first crack at events.
fn shutdown(&mut self, _ctx: &mut Context)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".