Loading...
Searching...
No Matches
ml::Animate Class Reference

Fluent animation controller bound to one object. More...

#include <Malena/Animation/Animate.h>

Public Member Functions

 Animate (const Animate &)=delete
 Animate (Positionable *owner)
 ~Animate ()
bool active () const
 True while any animation on this object is running.
void cancel ()
 Cancel every animation on this object (no completion callbacks fire).
Animatemove (sf::Vector2f to, float seconds, Easing::Fn ease=Easing::EaseOutCubic, std::function< void()> onComplete={})
 Animate the owner's position to to over seconds.
AnimatemoveBy (sf::Vector2f delta, float seconds, Easing::Fn ease=Easing::EaseOutCubic, std::function< void()> onComplete={})
 Animate the owner's position by a relative delta over seconds.
Animateoperator= (const Animate &)=delete
template<class T>
Animatevalue (T from, T to, float seconds, Easing::Fn ease, std::function< void(const T &)> apply, std::function< void()> onComplete={})
 Animate an arbitrary value and deliver it through apply.

Detailed Description

Fluent animation controller bound to one object.

comp.animate().move({400.f, 300.f}, 0.4f, Easing::EaseOutCubic);
comp.animate().moveBy({0.f, -20.f}, 0.2f);
comp.animate().value<sf::Color>(from, to, 0.3f, Easing::Linear,
[&](const sf::Color& c){ shape.setFillColor(c); });
static float Linear(float t)
Definition Easing.h:39
static float EaseOutCubic(float t)
Definition Easing.h:50

A new move / moveBy cancels this object's previous animations first, so position tweens never fight. Animations are automatically cancelled when the owning object is destroyed.

Definition at line 43 of file Animate.h.

Constructor & Destructor Documentation

◆ Animate() [1/2]

ml::Animate::Animate ( Positionable * owner)
inlineexplicit

Definition at line 46 of file Animate.h.

◆ ~Animate()

ml::Animate::~Animate ( )
inline

Definition at line 47 of file Animate.h.

◆ Animate() [2/2]

ml::Animate::Animate ( const Animate & )
delete

Member Function Documentation

◆ active()

bool ml::Animate::active ( ) const
nodiscard

True while any animation on this object is running.

◆ cancel()

void ml::Animate::cancel ( )

Cancel every animation on this object (no completion callbacks fire).

◆ move()

Animate & ml::Animate::move ( sf::Vector2f to,
float seconds,
Easing::Fn ease = Easing::EaseOutCubic,
std::function< void()> onComplete = {} )

Animate the owner's position to to over seconds.

◆ moveBy()

Animate & ml::Animate::moveBy ( sf::Vector2f delta,
float seconds,
Easing::Fn ease = Easing::EaseOutCubic,
std::function< void()> onComplete = {} )

Animate the owner's position by a relative delta over seconds.

◆ operator=()

Animate & ml::Animate::operator= ( const Animate & )
delete

◆ value()

template<class T>
Animate & ml::Animate::value ( T from,
T to,
float seconds,
Easing::Fn ease,
std::function< void(const T &)> apply,
std::function< void()> onComplete = {} )
inline

Animate an arbitrary value and deliver it through apply.

The engine is type-generic (float / sf::Vector2f / sf::Color); the caller supplies the setter, so this drives color, scale, opacity, scroll — anything lerpable — without Animate needing to know the property.

Definition at line 70 of file Animate.h.


The documentation for this class was generated from the following file: