[][src]Struct wasm_stopwatch::Stopwatch

pub struct Stopwatch { /* fields omitted */ }

Implementations

impl Stopwatch[src]

A stopwatch which tracks time in seconds.

pub fn new() -> Self[src]

Creates a new stopwatch with the current time set to 0.

pub fn with_speed(speed: f64) -> Self[src]

Creates a stopwatch which advances the given amount every second.

For instance, Stopwatch::with_speed(1.0/60.0) creates a stopwatch which uses minutes as the time unit instead of seconds.

pub fn paused(&self) -> bool[src]

Returns whether the stopwatch is paused.

pub fn pause(&mut self)[src]

Pauses the stopwatch. If the stopwatch was already paused, this does nothing.

pub fn unpause(&mut self)[src]

Unpauses the stopwatch. If the stopwatch was already unpaused, this does nothing.

pub fn toggle_pause(&mut self)[src]

Toggles whether the stopwatch is paused.

pub fn get_time(&self) -> f64[src]

Gets the current time.

pub fn set_time(&mut self, cur_time: f64)[src]

Sets the current time.

pub fn reset(&mut self)[src]

Resets the stopwatch to zero.

pub fn add_time(&mut self, time_diff: f64)[src]

Advances the stopwatch by time_diff.

pub fn sleep_until(&self, time: f64)[src]

Sleeps until this stopwatch reaches the given time. May sleep for slightly longer than requested (the same behavior as std::thread::sleep), so in practice most games should use vsync or similar mechanisms instead of using this to maintain a certain frame rate.

Panics if the stopwatch is paused.

Trait Implementations

impl Clone for Stopwatch[src]

impl Default for Stopwatch[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.