pub trait App<A: AppAssetId> {
// Required methods
fn advance(&mut self, seconds: f64, ctx: &mut AppContext<A>);
fn key_down(&mut self, key: KeyCode, ctx: &mut AppContext<A>);
fn render(&mut self, renderer: &mut Renderer<A>, ctx: &AppContext<A>);
// Provided methods
fn start(&mut self, _ctx: &mut AppContext<A>) { ... }
fn key_up(&mut self, _key: KeyCode, _ctx: &mut AppContext<A>) { ... }
}Expand description
Trait that a user can implement to specify application behavior, passed into gate::run(...).
Required Methods§
Sourcefn advance(&mut self, seconds: f64, ctx: &mut AppContext<A>)
fn advance(&mut self, seconds: f64, ctx: &mut AppContext<A>)
Advances the app state by a given amount of seconds (usually a fraction of a second).
Sourcefn key_down(&mut self, key: KeyCode, ctx: &mut AppContext<A>)
fn key_down(&mut self, key: KeyCode, ctx: &mut AppContext<A>)
Invoked when a key or mouse button is pressed down.
Sourcefn render(&mut self, renderer: &mut Renderer<A>, ctx: &AppContext<A>)
fn render(&mut self, renderer: &mut Renderer<A>, ctx: &AppContext<A>)
Render the app in its current state.
Provided Methods§
Sourcefn start(&mut self, _ctx: &mut AppContext<A>)
fn start(&mut self, _ctx: &mut AppContext<A>)
Invoked when the application is first started, default behavior is a no-op.
Sourcefn key_up(&mut self, _key: KeyCode, _ctx: &mut AppContext<A>)
fn key_up(&mut self, _key: KeyCode, _ctx: &mut AppContext<A>)
Invoked when a key or mouse button is released, default behavior is a no-op.