Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Animation.h"
- Animation::Animation(Texture* texture, Vector2u imageCount, float switchTime)
- {
- this->imageCount = imageCount;
- this->switchTime = switchTime;
- totalTime = 0.0f;
- currentImage.x = 0;
- uvRect.width = int(texture->getSize().x / float(imageCount.x));
- uvRect.height = int(texture->getSize().y / float(imageCount.y));
- }
- Animation::~Animation()
- {
- }
- void Animation::Update(int row, float deltaTime)
- {
- currentImage.y = row;
- if (totalTime >= switchTime)
- {
- totalTime -= switchTime;
- currentImage.x++;
- if (currentImage.x >= imageCount.x)
- {
- currentImage.x = 0;
- }
- }
- uvRect.left = currentImage.x * uvRect.width;
- uvRect.top = currentImage.y * uvRect.height;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement