PolyScreenSprite.h 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #pragma once
  10. #include "PolyString.h"
  11. #include "PolyGlobals.h"
  12. #include "PolyCoreServices.h"
  13. #include "PolyScreenShape.h"
  14. #include <vector>
  15. #include <string>
  16. namespace Polycode {
  17. class SpriteAnimation {
  18. public:
  19. float speed;
  20. String name;
  21. int numFrames;
  22. vector<Vector2> framesOffsets;
  23. };
  24. class ScreenSprite : public ScreenShape
  25. {
  26. public:
  27. ScreenSprite(String fileName, float spriteWidth, float spriteHeight);
  28. ~ScreenSprite();
  29. void addAnimation(String name, String frames, float speed);
  30. void playAnimation(String name, int startFrame, bool once);
  31. void Update();
  32. private:
  33. float spriteWidth;
  34. float spriteHeight;
  35. bool playingOnce;
  36. float lastTick;
  37. float spriteUVWidth;
  38. float spriteUVHeight;
  39. int currentFrame;
  40. SpriteAnimation *currentAnimation;
  41. vector<SpriteAnimation*> animations;
  42. };
  43. }