-
Notifications
You must be signed in to change notification settings - Fork 9
/
AnimationController.cpp
68 lines (60 loc) · 1.31 KB
/
AnimationController.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "AnimationController.h"
AnimationController::AnimationController()
{
animationQueue = new std::vector<Animation*>();
}
AnimationController::~AnimationController()
{
}
void AnimationController::tick()
{
std::vector<Animation*>::iterator i = animationQueue->begin();
while (i != animationQueue->end())
{
(*i)->tick();
i++;
}
std::vector<Animation*>::iterator it = animationQueue->begin();
for (it = animationQueue->begin(); it != animationQueue->end(); )
{
if ((*it)->isCompleted())
{
it = animationQueue->erase(it);
}
else{
++it;
}
}
}
void AnimationController::addAnimation(Animation* anim)
{
Uint32 t = SDL_GetTicks();
anim->setAnimationStartTime(t);
animationQueue->push_back(anim);
}
bool AnimationController::isAnimating(DrawableEntity* ent)
{
std::vector<Animation*>::iterator i = animationQueue->begin();
for (; i != animationQueue->end(); i++)
{
if ((*i)->getSourceObj() == ent)
return true;
}
return false;
}
bool AnimationController::checkAnyAnimation()
{
return (animationQueue->size() != 0);
}
int AnimationController::getAnimationCount()
{
return animationQueue->size();
}
void AnimationController::addAnimation(std::vector<Animation*>* anims)
{
std::vector<Animation*>::iterator i = anims->begin();
for (; i != anims->end(); i++)
{
addAnimation(*i);
}
}