pub trait App<A: AppAssetId> {
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>);
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.