Document repeating timer tick behavior

This commit is contained in:
Oliver Nordbjerg 2025-07-14 18:04:08 +02:00
parent b01de70bdd
commit c936cb349b
No known key found for this signature in database
GPG Key ID: 3B182D3AD953AB4B

View File

@ -5,13 +5,25 @@ use core::time::Duration;
/// Tracks elapsed time. Enters the finished state once `duration` is reached. /// Tracks elapsed time. Enters the finished state once `duration` is reached.
/// ///
/// Non repeating timers will stop tracking and stay in the finished state until reset. /// Note that in order to advance the timer [`tick`](Timer::tick) **MUST** be called.
/// Repeating timers will only be in the finished state on each tick `duration` is reached or ///
/// # Timer modes
///
/// There are two timer modes ([`TimerMode`]):
///
/// - Non repeating timers will stop tracking and stay in the finished state until reset.
/// - Repeating timers will only be in the finished state on each tick `duration` is reached or
/// exceeded, and can still be reset at any given point. /// exceeded, and can still be reset at any given point.
/// ///
/// Paused timers will not have elapsed time increased. /// # Pausing timers
/// ///
/// Note that in order to advance the timer [`tick`](Timer::tick) **MUST** be called. /// You can pause a timer using [`Timer::pause`]. Paused timers will not have elapsed time increased.
///
/// # Elapsing multiple times a frame
///
/// Repeating timers might elapse multiple times per frame if the time is advanced by more than the timer duration.
/// You can check how many times a timer elapsed each tick with [`Timer::times_finished_this_tick`].
/// For non-repeating timers, this will always be 0 or 1.
#[derive(Clone, Debug, Default, PartialEq, Eq)] #[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr( #[cfg_attr(