-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimator.h
More file actions
41 lines (31 loc) · 781 Bytes
/
Animator.h
File metadata and controls
41 lines (31 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <vector>
#include <SFML/Graphics.hpp>
/// <summary>
/// Represents an animator that animates spritesheets
/// </summary>
class Animator
{
public:
Animator(sf::Texture texture, int rows, int col, int speed, int endFrames);
void SetUpFrames(int animChoice);
void AnimateFrames();
sf::IntRect getCurrentFrame() {
return frames.at(static_cast<int>(fmin(frame, col - 1)));
}
bool getAnimationStatus() {
return animationEnded;
}
private:
// Frames selected from the spritesheet
std::vector<sf::IntRect> frames;
int frame; // current frame
// Properties of the spritesheet
sf::Texture texture;
int rows, col;
// Properties of the animation
int timer;
int speed;
int endFrames;
bool animationEnded; // True when the animation ends
};