-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationComponent.h
More file actions
58 lines (46 loc) · 1.28 KB
/
Copy pathAnimationComponent.h
File metadata and controls
58 lines (46 loc) · 1.28 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
enum AnimationState
{
MovingRight,
MovingLeft,
Jumping,
Falling,
Idle,
MaxAnimations
};
class AnimationComponent
{
private:
sf::Vector2f& m_velocity;
sf::Sprite& m_sprite;
sf::Clock m_runningAnimationTimer;
sf::Clock m_idleAnimationTimer;
AnimationState m_animationState;
sf::IntRect m_currentFrame;
sf::Vector2f m_spriteScale;
sf::IntRect m_basicFrame;
sf::IntRect m_fallingFrame;
sf::IntRect m_jumpingFrame;
float m_walkNextFrameDistance;
float m_walkMaxBound;
float m_topWalkBound;
float m_idleNextFrameDistance;
float m_idleMaxBound;
float m_topidleBound;
bool m_animationSwitch;
public:
AnimationComponent(sf::Sprite& m_sprite, sf::Vector2f& velocity);
~AnimationComponent();
void update();
void updateAnimationState();
void updateAnimation();
void playAnimation(sf::Clock& animationTimer,
float nextFrameDistance, float maxBound, float delay);
void setFrame(sf::IntRect firstFrameBounds);
void setSpriteRotation();
void setScale(sf::Vector2f scale);
void setBacisFrame(sf::IntRect basicFrame);
void setJumpingAndFallingFrame(sf::IntRect jumpingFrame, sf::IntRect fallingFrame);
void setAnimationBounds(float walkNextFrameDistance, float walkMaxBound, float topWalkBound,
float idleNextFrameDistance, float idleMaxBound, float topidleBound);
};