Trait rain2d::core::RainApp[][src]

pub trait RainApp {
    fn on_start(&mut self) { ... }
fn on_update(&mut self, rain: &mut RainCore, dt: Duration) { ... }
fn on_exit(&mut self) { ... } }

Trait used to call event functions from main loop

It’s not required to implement any of these functions although you probably want to or nothing will happen

Example

use rain2d::core::*;

struct App;

impl RainApp for App {
    // setup
    fn on_start(&mut self) {}

    // main loop
    fn on_update(&mut self, rain: &mut RainCore, dt: std::time::Duration) {}

    // cleanup
    fn on_exit(&mut self) {}
}

let mut core = RainCore::init("example app",
    640,
    360,
    true);

core.run(&mut App {});

Provided methods

fn on_start(&mut self)[src]

Called once when the application starts

Used to do any setup required by the main application

fn on_update(&mut self, rain: &mut RainCore, dt: Duration)[src]

Called every frame

dt is the time since the last update

fn on_exit(&mut self)[src]

Called before the application exits

Used to clean up before exiting the main application

Loading content...

Implementors

Loading content...