2013-12-13 03:17:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "animations/Animation.h"
|
2013-12-13 03:17:59 +00:00
|
|
|
|
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.
|
2013-12-13 03:17:59 +00:00
|
|
|
class LambdaAnimation : public Animation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LambdaAnimation(const std::function<void(float t)>& func, int duration) : mFunction(func), mDuration(duration) {}
|
|
|
|
|
2017-07-28 07:57:37 +00:00
|
|
|
virtual ~LambdaAnimation() = default;
|
|
|
|
|
2013-12-13 03:17:59 +00:00
|
|
|
int getDuration() const override { return mDuration; }
|
|
|
|
|
|
|
|
void apply(float t) override
|
|
|
|
{
|
|
|
|
mFunction(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::function<void(float t)> mFunction;
|
|
|
|
int mDuration;
|
|
|
|
};
|