Animations.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "Base.h"
  2. #include "Animations.h"
  3. namespace gameplay
  4. {
  5. Animations::Animations(void)
  6. {
  7. // There will only be one Animations.
  8. // It requires an ID because it will be stores in the ref table.
  9. setId("__Animations__");
  10. }
  11. Animations::~Animations(void)
  12. {
  13. }
  14. unsigned int Animations::getTypeId(void) const
  15. {
  16. return ANIMATIONS_ID;
  17. }
  18. const char* Animations::getElementName(void) const
  19. {
  20. return "Animations";
  21. }
  22. void Animations::writeBinary(FILE* file)
  23. {
  24. Object::writeBinary(file);
  25. write(_animations.size(), file);
  26. for (std::vector<Animation*>::iterator i = _animations.begin(); i != _animations.end(); ++i)
  27. {
  28. (*i)->writeBinary(file);
  29. }
  30. }
  31. void Animations::writeText(FILE* file)
  32. {
  33. fprintElementStart(file);
  34. if (_animations.size() > 0 )
  35. {
  36. for (std::vector<Animation*>::iterator i = _animations.begin(); i != _animations.end(); ++i)
  37. {
  38. (*i)->writeText(file);
  39. }
  40. }
  41. fprintElementEnd(file);
  42. }
  43. void Animations::add(Animation* animation)
  44. {
  45. _animations.push_back(animation);
  46. }
  47. unsigned int Animations::getAnimationCount() const
  48. {
  49. return _animations.size();
  50. }
  51. Animation* Animations::getAnimation(unsigned int index) const
  52. {
  53. return _animations[index];
  54. }
  55. }