-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animation.cpp
54 lines (48 loc) · 1000 Bytes
/
Animation.cpp
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
49
50
51
52
53
54
#include "Animation.h"
//Class thats a fancy counter to iterate through a list
//see header for more detail
Animation::Animation(int pMaxFrames, float pAnimateSpeed, bool pIsEscalator) :
mMaxFrames(pMaxFrames),
mAnimateSpeed(pAnimateSpeed),
isEscalator(pIsEscalator)
{
mCurrentFrame = 0;
isUpOrDown = true;
}
Animation::~Animation(void)
{
}
//iterate through array to change current frame
void Animation::animate()
{
//if its time to iterate based on animation speed
if(mClock.getElapsedTime().asSeconds() > mAnimateSpeed){
//escalator is what im calling 1234321 instead of 12341234
if(isEscalator)
{
if(isUpOrDown)
{
mCurrentFrame++;
if(mCurrentFrame == mMaxFrames -1)
isUpOrDown = false;
}
else
{
mCurrentFrame--;
if(mCurrentFrame == 0)
isUpOrDown = true;
}
}
else
{
mCurrentFrame++;
mCurrentFrame %= mMaxFrames;
}
mClock.restart();
}
}
//go back to first frame
void Animation::resetAnimation()
{
mCurrentFrame = 0;
}