Struct Timer Copy item path Source pub struct Timer {
pub duration: f64 ,
pub elapsed: f64 ,
}Expand description A countdown timer that fires after a fixed duration, optionally repeating.
Timers are updated with the frame delta time; Timer::update returns
the number of times the timer fired during that update (0 or 1 for
one-shot timers, possibly more for repeating timers after a long frame).
The countdown duration in seconds.
The time accumulated since the timer started or last fired.
Source § Implements creation and countdown logic for Timer.
Creates a one-shot timer that fires once after duration seconds.
§ Arguments
f64 - The countdown duration in seconds.
§ Returns
Timer - The new one-shot timer.
Creates a repeating timer that fires every duration seconds.
§ Arguments
f64 - The interval between firings in seconds.
§ Returns
Timer - The new repeating timer.
Advances the timer by the given delta time.
§ Arguments
f64 - The time elapsed since the last update, in seconds.
§ Returns
u32 - The number of times the timer fired during this update.
Resets the timer to its initial state so it can count down again.
Pauses the timer, preserving the accumulated elapsed time.
Returns whether the timer is currently paused.
§ Returns
Returns whether a one-shot timer has fired and stopped.
§ Returns
Returns the countdown progress in the range 0.0 to 1.0.
§ Returns
f64 - The progress ratio.
Returns the time remaining until the next firing, in seconds.
§ Returns
f64 - The remaining time.
Performs copy-assignment from
source.
Read more Formats the value using the given formatter.
Read more This method returns an ordering between
self and
other values if one exists.
Read more Tests less than (for
self and
other) and is used by the
< operator.
Read more Tests less than or equal to (for
self and
other) and is used by the
<= operator.
Read more Tests greater than (for
self and
other) and is used by the
>
operator.
Read more Tests greater than or equal to (for
self and
other) and is used by
the
>= operator.
Read more Source § Forwards Timer::update through the Updatable trait so timers can
participate in the same generic update loop as entities, animators,
scenes, and physics worlds.
Advances the simulation by delta_time seconds.
§ Arguments
f64 - Seconds elapsed since the previous update.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From <T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Perform a zero-cost type-safe upcast to a wider ref type within the Wasm
bindgen generics type system.
Read more Perform a zero-cost type-safe upcast to a wider type within the Wasm
bindgen generics type system.
Read more