-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveAnimation.h
More file actions
30 lines (27 loc) · 858 Bytes
/
MoveAnimation.h
File metadata and controls
30 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef MOVEANIMATION_h
#define MOVEANIMATION_h
#include <SFML/Graphics.hpp>
using namespace sf;
class MoveAnimation { // custom movement animation for thor::animator
public:
enum Mode
{
uniform, accelerate, decelerate, ac_de, de_ac, settle
};
MoveAnimation(Vector2f relative_destination, Mode movement_mode);
template <class T>
void operator()(T& object, double progress);
bool is_idle();
double getProgress() const { return this->progress; }
void reset() { firstCall = true; progress = 0.0; }
void reset(Vector2f relative_destination, Mode movement_mode);
void setDestination(Vector2f relative_destination) { this->destination = relative_destination; }
void setMode(Mode mode) { this->mode = mode; }
private:
Vector2f source;
Vector2f destination;
Mode mode;
bool firstCall = true;
double progress = 0.0;
};
#endif // !MOVEANIMATION_h