pub struct Timer { /* private fields */ }
Expand description
The Timer struct calculates delta time and if fixed updates should be done to calculate the times, the crate’s stopwatch is used
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new timer object time since last fixed update is set to a high number on creation to get a fixed update on start
Sourcepub fn time_since_start(&self) -> Duration
pub fn time_since_start(&self) -> Duration
Get the time since start of the timer
Sourcepub fn update_delta_time(&mut self)
pub fn update_delta_time(&mut self)
update the delta time and time since start place this on the beginning of the loop
Sourcepub fn update_fixed_time(&mut self)
pub fn update_fixed_time(&mut self)
update the time since last fixed update place this after update delta time this function is not required if no fixed update is used
Sourcepub fn should_fixed_update(&self) -> bool
pub fn should_fixed_update(&self) -> bool
returns a bool if a fixed update should be done this function is not required if no fixed update is used
Sourcepub fn set_fixed_interval(&mut self, fixed_interval: Duration)
pub fn set_fixed_interval(&mut self, fixed_interval: Duration)
set the interval of a fixed update in seconds this function is not required if no fixed update is used
Sourcepub fn delta_time(&self) -> Duration
pub fn delta_time(&self) -> Duration
public getter for the delta time
Sourcepub fn fixed_interval(&self) -> Duration
pub fn fixed_interval(&self) -> Duration
public getter for the delta fixed interval
Sourcepub fn time_since_last_fixed(&self) -> Duration
pub fn time_since_last_fixed(&self) -> Duration
public getter for the time since the last fixed update