Skip to main content

Clock

Trait Clock 

Source
pub trait Clock {
    // Required method
    fn delta(&mut self) -> f32;
}
Expand description

Abstracts any time source that can produce a dt (delta-time) value in seconds.

Implement this for custom timers, game-engine time sources, or scroll-based drivers.

§Example

use animato_driver::{Clock, MockClock};

let mut clk = MockClock::new(1.0 / 60.0);
assert!((clk.delta() - 1.0 / 60.0).abs() < 1e-6);

Required Methods§

Source

fn delta(&mut self) -> f32

Returns seconds elapsed since the last call.

The first call returns 0.0 for WallClock, or the configured step for MockClock / ManualClock.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§