pub struct Timer { /* private fields */ }Expand description
Game-owned timer, advanced explicitly by simulation or wall-clock time.
A repeated timer returns the number of crossed periods, so a long update cannot silently lose scheduled events. Pausing never queues elapsed time.
Implementations§
Source§impl Timer
impl Timer
Sourcepub fn once(duration: Duration) -> Self
pub fn once(duration: Duration) -> Self
Timer that completes once. A zero duration completes on its first advance.
Sourcepub fn advance(&mut self, elapsed: Duration) -> u32
pub fn advance(&mut self, elapsed: Duration) -> u32
Advances by a duration and returns completions (saturated at u32::MAX).
Sourcepub fn finished(&self) -> bool
pub fn finished(&self) -> bool
Whether a one-shot timer has completed. Repeated timers never finish.
Sourcepub fn fraction(&self) -> f32
pub fn fraction(&self) -> f32
Progress from zero to one; repeated timers report their current period.
Sourcepub fn set_paused(&mut self, paused: bool)
pub fn set_paused(&mut self, paused: bool)
Pauses/resumes the timer without accumulating elapsed time while paused.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Timer
impl RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl UnsafeUnpin for Timer
impl UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more