hx3d  1
2D/3D Simple Game Framework
tween_manager.cpp
1 
2 /*
3  Tween management.
4  Copyright (C) 2015 Denis BOURGE
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19  USA
20 */
21 
22 #include "hx3d/tweens/tween_manager.hpp"
23 
24 namespace hx3d {
25 namespace tweens {
26 
27 TweenManager::TweenManager() {}
28 
29 void TweenManager::add(const Ptr<BaseTween>& tween) {
30  tweens.push_back(tween);
31 }
32 
33 void TweenManager::update(const float delta) {
34  for (auto i = tweens.begin(); i != tweens.end();) {
35  const Ptr<BaseTween>& tween = *i;
36  if (tween->hasEnded()) {
37  tweens.erase(i);
38  } else {
39  tween->update(delta);
40  ++i;
41  }
42  }
43 }
44 
46  return tweens.size();
47 }
48 
50  tweens.clear();
51 }
52 
53 } /* tween */
54 } /* hx3d */
void update(const float delta)
Update all tweens.
hx3d framework namespace
Definition: audio.hpp:26
void add(const Ptr< BaseTween > &tween)
Add an existing tween.
unsigned int getTweenCount()
Get the tweens count.
void clear()
Clear all the tweens.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34