ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
Animation.h
浏览该文件的文档.
1
#pragma once
2
3
#include "
../Core/Core.h
"
4
#include <SDL3/SDL_rect.h>
5
#include <string>
6
#include <vector>
7
8
namespace
Shit
{
16
class
SHIT_API
Animation
final {
17
public
:
18
Animation
(
float
duration = 0.1f,
bool
loop =
true
);
19
~Animation
();
20
21
void
addFrame
(
const
SDL_FRect& frame);
22
void
addFrames
(
const
std::vector<SDL_FRect>& frames);
23
24
SDL_FRect
getFrame
(
float
elapsedTime)
const
;
25
26
// --- getter & setter ---
27
void
setLoop
(
bool
loop) { m_loop = loop; }
28
void
setDuration
(
float
duration) { m_duration = duration; }
29
30
bool
isLooping
()
const
{
return
m_loop; }
31
float
getDuration
()
const
{
return
m_duration; }
32
int
getFrameCount
()
const
{
return
static_cast<
int
>
(m_frames.size()); }
33
34
private
:
35
std::vector<SDL_FRect> m_frames;
36
float
m_duration;
37
bool
m_loop =
true
;
38
};
39
}
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:12
Shit::Animation::getFrameCount
int getFrameCount() const
定义
Animation.h:32
Shit::Animation::getDuration
float getDuration() const
定义
Animation.h:31
Shit::Animation::getFrame
SDL_FRect getFrame(float elapsedTime) const
根据已播放时间返回当前帧的源矩形
Shit::Animation::Animation
Animation(float duration=0.1f, bool loop=true)
Shit::Animation::isLooping
bool isLooping() const
定义
Animation.h:30
Shit::Animation::setDuration
void setDuration(float duration)
定义
Animation.h:28
Shit::Animation::setLoop
void setLoop(bool loop)
定义
Animation.h:27
Shit::Animation::addFrames
void addFrames(const std::vector< SDL_FRect > &frames)
批量添加帧
Shit::Animation::~Animation
~Animation()
Shit::Animation::addFrame
void addFrame(const SDL_FRect &frame)
添加单帧
Shit
定义
AudioPlayer.h:9
ShitEngine
Render
Animation.h
制作者
1.17.0