hx3d  1
2D/3D Simple Game Framework
sequence.hpp
1 /*
2  Tween sequence.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_TWEENS_SEQUENCE
22 #define HX3D_TWEENS_SEQUENCE
23 
24 #include "hx3d/math/interpolation.hpp"
25 
26 #include "hx3d/tweens/tween.hpp"
27 #include "hx3d/tweens/delay.hpp"
28 #include "hx3d/tweens/callback.hpp"
29 
30 #include "hx3d/utils/ptr.hpp"
31 
32 #include <queue>
33 #include <stack>
34 
35 namespace hx3d {
36 namespace tweens {
37 
41 class Sequence: public BaseTween {
42 public:
48  Sequence(bool infinite = false);
49 
58  template <class T>
59  void addTween(T& mod, const T to, const float duration, const math::Interpolation interp);
60 
66  void addDelay(const float delay);
67 
73  void addCallback(std::function<void()> func);
74 
80  void add(const Ptr<BaseTween>& tween);
81 
82  virtual void reset() override;
83  virtual void update(const float delta) override;
84 
85 private:
87  std::queue<Ptr<BaseTween>> tweens;
88  std::stack<Ptr<BaseTween>> doneTweens;
89 };
90 
91 } /* math */
92 } /* hx3d */
93 
94 #include "hx3d/tweens/_inline/sequence.inl.hpp"
95 
96 #endif
virtual void update(const float delta) override
Update the tween.
Definition: sequence.cpp:53
void addCallback(std::function< void()> func)
Create a callback tween.
Definition: sequence.cpp:33
Sequence(bool infinite=false)
Definition: sequence.cpp:26
void addDelay(const float delay)
Create a delay tween.
Definition: sequence.cpp:28
virtual void reset() override
Reset the tween.
Definition: sequence.cpp:42
hx3d framework namespace
Definition: audio.hpp:26
Interpolation
Interpolate using functions.
void addTween(T &mod, const T to, const float duration, const math::Interpolation interp)
Create a tween.
Sequential suite of tweens.
Definition: sequence.hpp:41
Base abstract tween.
Definition: base_tween.hpp:34
void add(const Ptr< BaseTween > &tween)
Add an existing tween.
Definition: sequence.cpp:38
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34