Lysa  0.0
Lysa 3D Engine
PropertyTween< T > Class Template Reference

Detailed Description

template<typename T>
class lysa::PropertyTween< T >

Tween that interpolates a property of an Object via a setter function.

The template parameter T is the property value type (e.g., float, float3). Each update computes the interpolated value and calls the provided setter on the target object. When the duration elapses, the tween stops and the optional completion callback is invoked.

+ Inheritance diagram for PropertyTween< T >:

Public Typedefs

typedef void (Object::* Setter) (const T &)
 
- Public Typedefs inherited from Tween
using Callback = std::function< void ()>
 

Public Member Functions

 PropertyTween (Object *obj, const Setter set, T initial, T final, const float duration, const TransitionType ttype=TransitionType::LINEAR, const Callback &callback=nullptr)
 
 PropertyTween (const std::shared_ptr< Object > &obj, const Setter set, T initial, T final, const float duration, const TransitionType ttype=TransitionType::LINEAR, const Callback &callback=nullptr)
 
bool update (const float deltaTime) override
 
- Public Member Functions inherited from Tween
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
 

Additional Inherited Members

- Protected Member Functions inherited from Tween
 Tween (const TransitionType type, const Callback &callback)
 
- Protected Attributes inherited from Tween
bool running {false}
 
Callback callback
 
TransitionType interpolationType
 

Member Typedef Documentation

typedef void(Object::* Setter) (const T &)

Pointer-to-member setter method called every update. The signature must accept a const T&.

Constructor & Destructor Documentation

PropertyTween ( Object obj,
const Setter  set,
initial,
final,
const float  duration,
const TransitionType  ttype = TransitionType::LINEAR,
const Callback callback = nullptr 
)
inline

Creates a tween that interpolates a property on an Object.

Parameters
objTarget object whose property will be animated.
setMember setter to call on the target object.
initialStarting value applied at time 0.
finalTarget value reached at the end of the duration.
durationAnimation duration in seconds (must be > 0).
ttypeInterpolation curve to use (default: LINEAR).
callbackOptional function invoked when the tween completes.
PropertyTween ( const std::shared_ptr< Object > &  obj,
const Setter  set,
initial,
final,
const float  duration,
const TransitionType  ttype = TransitionType::LINEAR,
const Callback callback = nullptr 
)
inline

Creates a tween that interpolates a property on an Object. This overload accepts a shared_ptr to the target; the pointer is not retained beyond construction (the raw pointer is stored), so callers must ensure the target outlives the tween.

Parameters
objShared pointer to the target object.
setMember setter to call on the target object.
initialStarting value applied at time 0.
finalTarget value reached at the end of the duration.
durationAnimation duration in seconds (must be > 0).
ttypeInterpolation curve to use (default: LINEAR).
callbackOptional function invoked when the tween completes.

Member Function Documentation

bool update ( const float  deltaTime)
inlineoverridevirtual

Interpolates the property and applies the new value through the setter.

If the tween was created manually, call this from a Node::onPhysicsProcess() function. Do not call it if the tween was created with Node::createPropertyTween().

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

Implements lysa::Tween::update()