The Table Engine
animation.h
Go to the documentation of this file.
1
#pragma once
2
8
#include "
texture.h
"
9
21
class
Animation
:
public
Texture
{
22
protected
:
23
int
m_rows
= 1;
24
int
m_cols
= 1;
25
float
m_time
= 1.0f;
26
int
m_numFrames
= 1;
27
int
m_msPerFrame
;
28
29
bool
m_isPlaying
=
true
;
30
int
m_currentFrame
= 0;
31
int
m_startTime
= 0;
32
int
m_pausedTime
= 0;
33
34
public
:
38
Animation
();
39
43
Animation
(SDL_Texture* texture);
44
49
int
getRows
();
50
55
int
getCols
();
56
61
int
getNumFrames
();
62
67
void
setAutoPlay
(
bool
autoplay);
68
72
void
setRowsColsInSpriteMap
(
int
rows,
int
cols);
73
77
void
setAnimationTime
(
float
time);
78
82
void
play
();
83
87
void
pause
();
88
93
void
setFrame
(
int
frame);
94
99
int
getCurrentFrame
()
const
{
return
m_currentFrame
; }
100
105
bool
isPlaying
()
const
{
return
m_isPlaying
; }
106
110
void
update
()
override
;
111
};
Animation
Component to handle animation of game objects. Derived from Texture.
Definition:
animation.h:21
Animation::setFrame
void setFrame(int frame)
Sets a specific frame of animation.
Definition:
animation.cpp:61
Animation::getNumFrames
int getNumFrames()
Get the total number of frames.
Definition:
animation.cpp:23
Animation::m_rows
int m_rows
Number of rows in the sprite sheet.
Definition:
animation.h:23
Animation::setRowsColsInSpriteMap
void setRowsColsInSpriteMap(int rows, int cols)
Sets the number of rows and columns in the sprite map.
Definition:
animation.cpp:34
Animation::pause
void pause()
Pauses the animation at current frame.
Definition:
animation.cpp:54
Animation::getCols
int getCols()
Get the number of columns.
Definition:
animation.cpp:19
Animation::m_pausedTime
int m_pausedTime
Time when animation was paused.
Definition:
animation.h:32
Animation::setAutoPlay
void setAutoPlay(bool autoplay)
Sets whether the animation should start playing automatically.
Definition:
animation.cpp:27
Animation::m_cols
int m_cols
Number of columns in the sprite sheet.
Definition:
animation.h:24
Animation::m_msPerFrame
int m_msPerFrame
Milliseconds per frame.
Definition:
animation.h:27
Animation::getRows
int getRows()
Get the number of rows.
Definition:
animation.cpp:15
Animation::getCurrentFrame
int getCurrentFrame() const
Gets the current frame number.
Definition:
animation.h:99
Animation::Animation
Animation()
Default constructor.
Definition:
animation.cpp:3
Animation::m_currentFrame
int m_currentFrame
Current frame of animation.
Definition:
animation.h:30
Animation::m_isPlaying
bool m_isPlaying
Whether the animation is currently playing.
Definition:
animation.h:29
Animation::play
void play()
Starts or resumes the animation.
Definition:
animation.cpp:47
Animation::isPlaying
bool isPlaying() const
Checks if animation is currently playing.
Definition:
animation.h:105
Animation::update
void update() override
Updates the animation state.
Definition:
animation.cpp:70
Animation::m_time
float m_time
Total animation time in seconds.
Definition:
animation.h:25
Animation::m_startTime
int m_startTime
Time when animation started/resumed.
Definition:
animation.h:31
Animation::m_numFrames
int m_numFrames
Total number of frames.
Definition:
animation.h:26
Animation::setAnimationTime
void setAnimationTime(float time)
Sets the total time for the animation cycle.
Definition:
animation.cpp:42
Texture
Component for handling textures in the game engine.
Definition:
texture.h:20
texture.h
Defines the Texture component for managing textures within the Game Engine, encapsulating SDL texture...
Engine
include
animation.h
Generated by
1.9.1