ShitEngine
1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
SpriteSheet.h
浏览该文件的文档.
1
#pragma once
2
3
#include "
../Core/Core.h
"
4
#include "
../Math.h
"
5
#include <vector>
6
#include <cstddef>
7
#include <algorithm>
8
9
namespace
Shit
{
10
23
class
SHIT_API
SpriteSheet
final {
24
public
:
25
SpriteSheet
(
int
rows,
int
cols,
float
frameWidth,
float
frameHeight,
26
float
margin = 0.0f,
float
spacing = 0.0f);
27
28
~SpriteSheet
() =
default
;
29
30
SpriteSheet
(
const
SpriteSheet
&) =
default
;
31
SpriteSheet
&
operator=
(
const
SpriteSheet
&) =
default
;
32
SpriteSheet
(
SpriteSheet
&&) noexcept = default;
33
SpriteSheet
& operator=(
SpriteSheet
&&) noexcept = default;
34
35
Rect
getFrameRect
(
int
frameIndex) const;
36
Rect
getFrameRect
(
int
row,
int
col) const;
37
38
int
getRows
()
const
{
return
m_rows; }
39
int
getCols
()
const
{
return
m_cols; }
40
float
getFrameWidth
()
const
{
return
m_frameWidth; }
41
float
getFrameHeight
()
const
{
return
m_frameHeight; }
42
float
getMargin
()
const
{
return
m_margin; }
43
float
getSpacing
()
const
{
return
m_spacing; }
44
int
getFrameCount
()
const
{
return
m_rows * m_cols; }
45
46
void
setRows
(
int
rows) { m_rows = std::max(1, rows); }
47
void
setCols
(
int
cols) { m_cols = std::max(1, cols); }
48
void
setFrameWidth
(
float
width) { m_frameWidth = std::max(0.0f, width); }
49
void
setFrameHeight
(
float
height) { m_frameHeight = std::max(0.0f, height); }
50
void
setMargin
(
float
margin) { m_margin = std::max(0.0f, margin); }
51
void
setSpacing
(
float
spacing) { m_spacing = std::max(0.0f, spacing); }
52
53
private
:
54
int
m_rows = 0;
55
int
m_cols = 0;
56
float
m_frameWidth = 0.0f;
57
float
m_frameHeight = 0.0f;
58
float
m_margin = 0.0f;
59
float
m_spacing = 0.0f;
60
};
61
62
}
// namespace Shit
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:14
Math.h
Shit::SpriteSheet::getFrameCount
int getFrameCount() const
定义
SpriteSheet.h:44
Shit::SpriteSheet::getSpacing
float getSpacing() const
定义
SpriteSheet.h:43
Shit::SpriteSheet::getCols
int getCols() const
定义
SpriteSheet.h:39
Shit::SpriteSheet::setSpacing
void setSpacing(float spacing)
定义
SpriteSheet.h:51
Shit::SpriteSheet::setMargin
void setMargin(float margin)
定义
SpriteSheet.h:50
Shit::SpriteSheet::setRows
void setRows(int rows)
定义
SpriteSheet.h:46
Shit::SpriteSheet::SpriteSheet
SpriteSheet(SpriteSheet &&) noexcept=default
Shit::SpriteSheet::setFrameHeight
void setFrameHeight(float height)
定义
SpriteSheet.h:49
Shit::SpriteSheet::getFrameRect
Rect getFrameRect(int frameIndex) const
Shit::SpriteSheet::getFrameHeight
float getFrameHeight() const
定义
SpriteSheet.h:41
Shit::SpriteSheet::getFrameWidth
float getFrameWidth() const
定义
SpriteSheet.h:40
Shit::SpriteSheet::operator=
SpriteSheet & operator=(const SpriteSheet &)=default
Shit::SpriteSheet::setCols
void setCols(int cols)
定义
SpriteSheet.h:47
Shit::SpriteSheet::setFrameWidth
void setFrameWidth(float width)
定义
SpriteSheet.h:48
Shit::SpriteSheet::~SpriteSheet
~SpriteSheet()=default
Shit::SpriteSheet::SpriteSheet
SpriteSheet(const SpriteSheet &)=default
Shit::SpriteSheet::getMargin
float getMargin() const
定义
SpriteSheet.h:42
Shit::SpriteSheet::getRows
int getRows() const
定义
SpriteSheet.h:38
Shit::SpriteSheet::SpriteSheet
SpriteSheet(int rows, int cols, float frameWidth, float frameHeight, float margin=0.0f, float spacing=0.0f)
Shit
定义
AnimationClip.h:12
Shit::Rect
Rectangle struct (float precision), with SDL_FRect conversion
定义
Math.h:10
include
ShitEngine
Render
SpriteSheet.h
制作者
1.17.0