-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweener.cpp
More file actions
executable file
·68 lines (55 loc) · 1.64 KB
/
Tweener.cpp
File metadata and controls
executable file
·68 lines (55 loc) · 1.64 KB
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
// Copyright 2006-12 HumaNature Studios Inc.
#include "Tweener.h"
#include "Misc.h"
namespace core {
TweenerImpl Tweener;
void TweenerImpl::update(float deltaSeconds)
{
// iterate through all tweens
for(auto i = mTweens.begin(); i != mTweens.end();)
{
auto tween = *i;
if(tween->isRemoved())
{
// if the tween is removed, erase it and update the iterator
SafeDelete(tween);
i = mTweens.erase(i);
}
else
{
// otherwise update the tween and increment the iterator
tween->update(deltaSeconds);
++i;
}
}
}
Tween& TweenerImpl::addTween(const char* name)
{
// allocate the tween
auto tween = new Tween(name);
// add to the list of all tweens
mTweens.push_back(tween);
// return a reference to the tween
return *tween;
}
void TweenerImpl::removeTween(Tween* tween)
{
// find the tween
auto i = std::find(mTweens.begin(), mTweens.end(), tween);
// mark it as removed, will be cleaned up during the next update
if (i != mTweens.end())
{
tween->remove();
}
}
void TweenerImpl::removeAllTweens()
{
// iterate through all the tweens and delete them
for(auto i = mTweens.begin(); i != mTweens.end(); ++i)
{
SafeDelete(*i);
}
// clear the list
mTweens.clear();
}
} // namespace core