-
Notifications
You must be signed in to change notification settings - Fork 3
/
animationcontroller.h
48 lines (36 loc) · 1.1 KB
/
animationcontroller.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <chrono>
/**
* AnimationController controls the timing of the animation.
* The primary purpose is to keep the animation synchronized between the various nodes.
* The secondary purpose (currently disabled) is to keep a constant animation rate despite changing framerate.
* To operate the getFrame function should be called once per graphics frame to get the animation frame to be rendered.
* It is critical to either use the constructor which specifies the number of frames or to manually set it using setFrameCount.
*/
class AnimationController
{
public:
AnimationController(int numFrames);
AnimationController();
void setFrameCount(int numFrames);
void setFrame(int frame);
int getFrame();
void setSpeed(float speed);
float getSpeed();
void increaseSpeed();
void decreaseSpeed();
void play();
void pause();
void togglePlay();
void stepForward();
void stepBackward();
private:
const float speedMultiplier = 1.05;
float speed;
int frameCount;
int currFrame;
bool playing = false;
double startTime;
double lastTime;
void ValidateSpeed();
};