2013-12-08 17:35:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <functional>
|
|
|
|
#include "Animation.h"
|
|
|
|
|
|
|
|
class AnimationController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// FinishedCallback is guaranteed to be called exactly once, even if the animation does not finish normally.
|
|
|
|
// Takes ownership of anim (will delete in destructor).
|
|
|
|
AnimationController(Animation* anim, std::function<void()> finishedCallback = nullptr, bool reverse = false);
|
|
|
|
virtual ~AnimationController();
|
|
|
|
|
2013-12-13 03:17:59 +00:00
|
|
|
// Returns true if the animation is complete.
|
|
|
|
bool update(int deltaTime);
|
2013-12-08 17:35:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Animation* mAnimation;
|
|
|
|
std::function<void()> mFinishedCallback;
|
|
|
|
bool mReverse;
|
|
|
|
int mTime;
|
|
|
|
};
|