ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
SpriteSheet类 参考final

Sprite sheet grid cutter 更多...

#include <SpriteSheet.h>

Public 成员函数

 SpriteSheet (int rows, int cols, float frameWidth, float frameHeight, float margin=0.0f, float spacing=0.0f)
 ~SpriteSheet ()=default
 SpriteSheet (const SpriteSheet &)=default
SpriteSheet & operator= (const SpriteSheet &)=default
 SpriteSheet (SpriteSheet &&) noexcept=default
SpriteSheet & operator= (SpriteSheet &&) noexcept=default
Rect getFrameRect (int frameIndex) const
Rect getFrameRect (int row, int col) const
int getRows () const
int getCols () const
float getFrameWidth () const
float getFrameHeight () const
float getMargin () const
float getSpacing () const
int getFrameCount () const
void setRows (int rows)
void setCols (int cols)
void setFrameWidth (float width)
void setFrameHeight (float height)
void setMargin (float margin)
void setSpacing (float spacing)

详细描述

Sprite sheet grid cutter

Cuts a texture arranged in "rows x cols" grid into per-frame source rectangles (Rect). Optional margin (padding around the edges) and spacing (gap between frames), in pixels.

Usage: Shit::SpriteSheet sheet(4, 8, 32, 32); // 4 rows, 8 cols, 32x32 per frame Rect f = sheet.getFrameRect(5); // global frame 5 std::vector<int> walk{0,1,2,3,4,5}; animComp->play("walk", &sheet, walk, 0.1f, true);

构造及析构函数说明

◆ SpriteSheet() [1/3]

SpriteSheet ( int rows,
int cols,
float frameWidth,
float frameHeight,
float margin = 0.0f,
float spacing = 0.0f )

◆ ~SpriteSheet()

~SpriteSheet ( )
default

◆ SpriteSheet() [2/3]

SpriteSheet ( const SpriteSheet & )
default

◆ SpriteSheet() [3/3]

SpriteSheet ( SpriteSheet && )
defaultnoexcept

成员函数说明

◆ getCols()

int getCols ( ) const
inline

◆ getFrameCount()

int getFrameCount ( ) const
inline

◆ getFrameHeight()

float getFrameHeight ( ) const
inline

◆ getFrameRect() [1/2]

Rect getFrameRect ( int frameIndex) const

◆ getFrameRect() [2/2]

Rect getFrameRect ( int row,
int col ) const

◆ getFrameWidth()

float getFrameWidth ( ) const
inline

◆ getMargin()

float getMargin ( ) const
inline

◆ getRows()

int getRows ( ) const
inline

◆ getSpacing()

float getSpacing ( ) const
inline

◆ operator=() [1/2]

SpriteSheet & operator= ( const SpriteSheet & )
default

◆ operator=() [2/2]

SpriteSheet & operator= ( SpriteSheet && )
defaultnoexcept

◆ setCols()

void setCols ( int cols)
inline

◆ setFrameHeight()

void setFrameHeight ( float height)
inline

◆ setFrameWidth()

void setFrameWidth ( float width)
inline

◆ setMargin()

void setMargin ( float margin)
inline

◆ setRows()

void setRows ( int rows)
inline

◆ setSpacing()

void setSpacing ( float spacing)
inline

该类的文档由以下文件生成: