2013-12-08 17:35:43 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_ANIMATIONS_ANIMATION_CONTROLLER_H
|
|
|
|
#define ES_CORE_ANIMATIONS_ANIMATION_CONTROLLER_H
|
2013-12-08 17:35:43 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <functional>
|
2014-06-20 01:30:09 +00:00
|
|
|
#include "animations/Animation.h"
|
2013-12-08 17:35:43 +00:00
|
|
|
|
|
|
|
class AnimationController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Takes ownership of anim (will delete in destructor).
|
2014-04-18 17:19:46 +00:00
|
|
|
AnimationController(Animation* anim, int delay = 0, std::function<void()> finishedCallback = nullptr, bool reverse = false);
|
2013-12-08 17:35:43 +00:00
|
|
|
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
|
|
|
|
2014-01-25 00:10:13 +00:00
|
|
|
inline bool isReversed() const { return mReverse; }
|
|
|
|
inline int getTime() const { return mTime; }
|
2014-04-18 17:19:46 +00:00
|
|
|
inline int getDelay() const { return mDelay; }
|
2014-04-15 02:03:11 +00:00
|
|
|
inline const std::function<void()>& getFinishedCallback() const { return mFinishedCallback; }
|
2014-04-18 17:19:46 +00:00
|
|
|
inline Animation* getAnimation() const { return mAnimation; }
|
2014-04-15 02:03:11 +00:00
|
|
|
|
|
|
|
inline void removeFinishedCallback() { mFinishedCallback = nullptr; }
|
2014-01-25 00:10:13 +00:00
|
|
|
|
2013-12-08 17:35:43 +00:00
|
|
|
private:
|
|
|
|
Animation* mAnimation;
|
|
|
|
std::function<void()> mFinishedCallback;
|
|
|
|
bool mReverse;
|
|
|
|
int mTime;
|
2014-04-18 17:19:46 +00:00
|
|
|
int mDelay;
|
2013-12-08 17:35:43 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_ANIMATIONS_ANIMATION_CONTROLLER_H
|