Skip to main content

Lifecycle

Trait Lifecycle 

Source
pub trait Lifecycle {
    // Required method
    fn on_update(&mut self, delta_time: f64);
}
Expand description

The common lifecycle stage shared by Component and Scene.

Both abstractions have a per-tick update callback (on_update), and both share the same f64 delta-time argument. Lifting that single method into a supertrait lets generic code iterate over mixed collections (e.g. a registry of components and scenes) and call on_update uniformly.

Component adds on_start, on_render with a Transform2D, on_destroy, and name. Scene adds on_enter, on_render without a transform, on_exit, and name. Lifecycle intentionally exposes only the shared surface — the domain-specific entry/exit and render hooks stay on the sub-traits where their semantics differ.

Required Methods§

Source

fn on_update(&mut self, delta_time: f64)

Advances the object’s internal state by the given delta time.

§Arguments
  • f64 - The delta time in seconds since the last update.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§