Lysa  0.0
Lysa 3D Engine
Tween Class Referenceabstract

Detailed Description

Base class for time-based animations (tweens). Tweens encapsulate a small, focused animation task that progresses with time, typically driven every physics tick. Common examples include interpolating a property value on a target Object over a given duration, then optionally invoking a completion callback.

Usage:

  • If a Tween is created manually, call update(deltaTime) from Node::onPhysicsProcess() to advance it.
  • If a Tween is created through Node::create*Tween() helpers, the engine will update it automatically; do not call update() yourself in that case.

Notes:

  • All tweens expose a running state that becomes false once the animation completes. The update() method conventionally returns true when the tween is finished and false while it is still running.
  • The TransitionType controls the interpolation curve. Concrete subclasses are responsible for applying it.
+ Inheritance diagram for Tween:

Public Typedefs

using Callback = std::function< void ()>
 

Public Member Functions

virtual bool update (float deltaTime) = 0
 
auto isRunning () const
 
void kill ()
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const std::function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual std::string toString () const
 
 Object () = default
 
virtual ~Object () = default
 

Protected Member Functions

 Tween (const TransitionType type, const Callback &callback)
 

Protected Attributes

bool running {false}
 
Callback callback
 
TransitionType interpolationType
 

Member Typedef Documentation

using Callback = std::function<void()>

Callback invoked when the tween completes (optional).

Constructor & Destructor Documentation

Tween ( const TransitionType  type,
const Callback callback 
)
inlineprotected

Constructs a tween with the given interpolation type and optional callback.

Parameters
typeInterpolation curve.
callbackFunction invoked on completion (may be nullptr).

Member Function Documentation

auto isRunning ( ) const
inline

Returns true while the tween is still animating.

void kill ( )
inline

Immediately stops the tween without firing the completion callback.

virtual bool update ( float  deltaTime)
pure virtual

Advances the tween by delta time.

Call this from Node::onPhysicsProcess() when the tween has been created manually. Do not call it for tweens created via Node::create*Tween(), as they are advanced by the engine.

Parameters
deltaTimeTime elapsed since the previous update (seconds).
Returns
true when the tween has finished, false while it is running.

Implemented in lysa::PropertyTween::update()

Member Data Documentation

Callback callback
protected

Optional completion callback invoked when the tween ends naturally.

TransitionType interpolationType
protected

Interpolation curve applied by the tween (e.g., linear, ease-in/out).

bool running {false}
protected

True while the tween is active. Set to false upon completion or kill().