AnimSpriteComponent.h 1.0 KB

123456789101112131415161718192021222324252627282930
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "SpriteComponent.h"
  10. #include <vector>
  11. class AnimSpriteComponent : public SpriteComponent
  12. {
  13. public:
  14. AnimSpriteComponent(class Actor* owner, int drawOrder = 100);
  15. // Update animation every frame (overridden from component)
  16. void Update(float deltaTime) override;
  17. // Set the textures used for animation
  18. void SetAnimTextures(const std::vector<SDL_Texture*>& textures);
  19. // Set/get the animation FPS
  20. float GetAnimFPS() const { return mAnimFPS; }
  21. void SetAnimFPS(float fps) { mAnimFPS = fps; }
  22. private:
  23. // All textures in the animation
  24. std::vector<SDL_Texture*> mAnimTextures;
  25. // Current frame displayed
  26. float mCurrFrame;
  27. // Animation frame rate
  28. float mAnimFPS;
  29. };