AnimationController.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef ANIMATIONCONTROLLER_H_
  2. #define ANIMATIONCONTROLLER_H_
  3. #include "AnimationClip.h"
  4. #include "Animation.h"
  5. #include "AnimationTarget.h"
  6. #include "Properties.h"
  7. namespace gameplay
  8. {
  9. /**
  10. * Defines a class for controlling game animation.
  11. */
  12. class AnimationController
  13. {
  14. friend class Game;
  15. friend class Animation;
  16. friend class AnimationClip;
  17. friend class SceneLoader;
  18. public:
  19. /**
  20. * Stops all AnimationClips currently playing on the AnimationController.
  21. */
  22. void stopAllAnimations();
  23. private:
  24. /**
  25. * The states that the AnimationController may be in.
  26. */
  27. enum State
  28. {
  29. RUNNING,
  30. IDLE,
  31. PAUSED,
  32. STOPPED
  33. };
  34. /**
  35. * Constructor.
  36. */
  37. AnimationController();
  38. /**
  39. * Constructor.
  40. */
  41. AnimationController(const AnimationController& copy);
  42. /**
  43. * Destructor.
  44. */
  45. ~AnimationController();
  46. /**
  47. * Gets the controller's state.
  48. *
  49. * @return The current state.
  50. */
  51. State getState() const;
  52. /**
  53. * Callback for when the controller is initialized.
  54. */
  55. void initialize();
  56. /*
  57. * Callback for when the controller is finalized.
  58. */
  59. void finalize();
  60. /**
  61. * Resumes the AnimationController.
  62. */
  63. void resume();
  64. /**
  65. * Pauses the AnimationController.
  66. */
  67. void pause();
  68. /**
  69. * Schedules an AnimationClip to run.
  70. */
  71. void schedule(AnimationClip* clip);
  72. /**
  73. * Unschedules an AnimationClip.
  74. */
  75. void unschedule(AnimationClip* clip);
  76. /**
  77. * Callback for when the controller receives a frame update event.
  78. */
  79. void update(long elapsedTime);
  80. State _state; // The current state of the AnimationController.
  81. std::list<AnimationClip*> _runningClips; // A list of running AnimationClips.
  82. };
  83. }
  84. #endif