Advertisement
Guest User

Untitled

a guest
May 30th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include "Animation.h"
  2.  
  3. Animation::Animation(Texture* texture, Vector2u imageCount, float switchTime)
  4. {
  5. this->imageCount = imageCount;
  6. this->switchTime = switchTime;
  7. totalTime = 0.0f;
  8. currentImage.x = 0;
  9. uvRect.width = int(texture->getSize().x / float(imageCount.x));
  10. uvRect.height = int(texture->getSize().y / float(imageCount.y));
  11. }
  12.  
  13. Animation::~Animation()
  14. {
  15.  
  16. }
  17.  
  18. void Animation::Update(int row, float deltaTime)
  19. {
  20. currentImage.y = row;
  21. if (totalTime >= switchTime)
  22. {
  23. totalTime -= switchTime;
  24. currentImage.x++;
  25. if (currentImage.x >= imageCount.x)
  26. {
  27. currentImage.x = 0;
  28. }
  29. }
  30. uvRect.left = currentImage.x * uvRect.width;
  31. uvRect.top = currentImage.y * uvRect.height;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement