| 1 | /*! | 
|---|
| 2 | * @file animation_player.h | 
|---|
| 3 | */ | 
|---|
| 4 |  | 
|---|
| 5 | #ifndef _ANIMATION_PLAYER_H | 
|---|
| 6 | #define _ANIMATION_PLAYER_H | 
|---|
| 7 |  | 
|---|
| 8 | #include "base_object.h" | 
|---|
| 9 | #include "animation.h" | 
|---|
| 10 |  | 
|---|
| 11 | /* FORWARD DECLARATION */ | 
|---|
| 12 |  | 
|---|
| 13 | //! A AnimationPlayer, that handles the animation of all the Animations in the scene. | 
|---|
| 14 | /** | 
|---|
| 15 | <b>AnimationPlayer usage:</b> \n | 
|---|
| 16 |  | 
|---|
| 17 | <b>Initialisation</b>: AnimationPlayer::getInstance() does the trick this is | 
|---|
| 18 | usually done when initializing a world \n | 
|---|
| 19 | <b>Adding Animations</b>: create an Animation the following Way: | 
|---|
| 20 | \li Anim* animation = new Anim(); // also use any other Subclass of Animation to initialize this | 
|---|
| 21 | \li set some parameters: also see the specific classes for more info | 
|---|
| 22 | \n | 
|---|
| 23 | if you do not want a specific Animation to be handled by the AnimationPlayer, you have to | 
|---|
| 24 | unload it explicitely with animation->doNotHandle(); | 
|---|
| 25 | \n | 
|---|
| 26 | eveything else will be done by the AnimationPlayer itself.\n | 
|---|
| 27 | */ | 
|---|
| 28 | class AnimationPlayer : public BaseObject { | 
|---|
| 29 |  | 
|---|
| 30 | public: | 
|---|
| 31 | /** @returns a Pointer to the only object of this Class */ | 
|---|
| 32 | inline static AnimationPlayer* getInstance() { if (!singletonRef) singletonRef = new AnimationPlayer();  return singletonRef; }; | 
|---|
| 33 |  | 
|---|
| 34 | virtual ~AnimationPlayer(); | 
|---|
| 35 |  | 
|---|
| 36 | // animation handling | 
|---|
| 37 | void addAnimation(Animation* animation); | 
|---|
| 38 | void removeAnimation(Animation* animation); | 
|---|
| 39 | void flush(); | 
|---|
| 40 |  | 
|---|
| 41 | // time functions | 
|---|
| 42 | void tick(float timePassed); | 
|---|
| 43 | void play(); | 
|---|
| 44 | void pause(); | 
|---|
| 45 |  | 
|---|
| 46 | Animation* getAnimationFromBaseObject(const BaseObject* baseObject) const; | 
|---|
| 47 |  | 
|---|
| 48 | void debug(); | 
|---|
| 49 |  | 
|---|
| 50 | private: | 
|---|
| 51 | /* singleton */ | 
|---|
| 52 | AnimationPlayer(); | 
|---|
| 53 | static AnimationPlayer*      singletonRef;          //!< SingletonReference to this class. | 
|---|
| 54 |  | 
|---|
| 55 | /* class specific */ | 
|---|
| 56 | tList<Animation>*            animationList;         //!< A List of Animations to be handled. | 
|---|
| 57 | bool                         bRunning;              //!< If the AnimationPlayer is running. | 
|---|
| 58 | }; | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | #endif /* _ANIMATION_PLAYER_H */ | 
|---|