ES-DE/es-core/src/animations/LambdaAnimation.h

24 lines
561 B
C
Raw Normal View History

#pragma once
#include "animations/Animation.h"
2014-01-24 22:21:10 +00:00
// Useful for simple one-off animations, you can supply the animation's apply(t) method right in the constructor as a lambda.
class LambdaAnimation : public Animation
{
public:
LambdaAnimation(const std::function<void(float t)>& func, int duration) : mFunction(func), mDuration(duration) {}
virtual ~LambdaAnimation() = default;
int getDuration() const override { return mDuration; }
void apply(float t) override
{
mFunction(t);
}
private:
std::function<void(float t)> mFunction;
int mDuration;
};