← API Reference Class

template<typename T> asge::math::Tween

Moves a value of type T (a float, a Float2, ...) from one value to another over a duration, shaped by an Easing.

#include <Tween.hpp>

Advance it with Update(), read it with Value(); it does not loop and holds no callbacks poll IsFinished() or Update()'s result.

Private Attributes

#T m_Fromprivate
#T m_Toprivate
#float m_Durationprivate
#float m_Elapsed { 0.0f }private
#Easing m_Easingprivate

Public Member Functions

#Tween(T inFrom, T inTo, float inDuration, Easing inEasing=Easing::Linear) noexcept

A tween from inFrom to inTo lasting inDuration seconds; a duration of 0 or less is finished at once.

#bool Update(float inDeltaTime) noexcept

Advances by inDeltaTime seconds, stopping at the end; returns true only on the call that finishes it.

#T Value() const noexcept

The eased value at the current time: the start before any Update, the end once finished.

#bool IsFinished() const noexcept

True once the full duration has elapsed (immediately, for a duration of 0 or less).

#void Reset() noexcept

Rewinds to the start so the tween can play again.