PolyScreenSprite.h 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * PolyScreenSprite.cpp
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 9/13/09.
  6. * Copyright 2009 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. #include "PolyGlobals.h"
  10. #include "PolyCoreServices.h"
  11. #include "PolyScreenShape.h"
  12. #include <vector>
  13. #include <string>
  14. namespace Polycode {
  15. class SpriteAnimation {
  16. public:
  17. float speed;
  18. string name;
  19. int numFrames;
  20. vector<Vector2> framesOffsets;
  21. };
  22. class ScreenSprite : public ScreenShape
  23. {
  24. public:
  25. ScreenSprite(string fileName, float spriteWidth, float spriteHeight);
  26. ~ScreenSprite();
  27. void addAnimation(string name, string frames, float speed);
  28. void playAnimation(string name, int startFrame, bool once);
  29. void Update();
  30. private:
  31. float spriteWidth;
  32. float spriteHeight;
  33. bool playingOnce;
  34. float lastTick;
  35. float spriteUVWidth;
  36. float spriteUVHeight;
  37. int currentFrame;
  38. SpriteAnimation *currentAnimation;
  39. vector<SpriteAnimation*> animations;
  40. };
  41. }