-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimation.cpp
More file actions
54 lines (42 loc) · 810 Bytes
/
Animation.cpp
File metadata and controls
54 lines (42 loc) · 810 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
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 "stdafx.h"
#include "Animation.h"
using namespace LarasEngine;
void Animation::Update(double lag)
{
elapsed = QDateTime::currentMSecsSinceEpoch() - activeSince;
if (!done)
{
Run(lag);
frameNr++;
}
}
bool AnimationHandler::AddAnimation(Animation* a, bool allowDuplicate)
{
bool ok = a != nullptr;
if (ok)
{
const std::string id = a->GetUniqeId();
if (!allowDuplicate)
ok = set.find(id) == set.end();
if (ok)
{
vec.push_back(Animation::Ptr(a));
set.insert(id);
}
}
return ok;
}
void AnimationHandler::RunAnimations(double lag)
{
for (Animation::Vec::iterator i = vec.begin(); i != vec.end();)
{
i->get()->Update(lag);
if (i->get()->Done())
i = vec.erase(i);
else
++i;
}
set.clear();
for (const auto& i : vec)
set.insert(i->GetUniqeId());
}