|
ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
精灵图集(sprite-sheet)网格切割器 更多...
#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 |
| SDL_FRect | getFrameRect (int frameIndex) const |
| 全局帧索引(0..rows*cols-1)对应的源矩形 | |
| SDL_FRect | getFrameRect (int row, int col) const |
| 指定行列(0 基)对应的源矩形 | |
| 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)网格切割器
把一张按“rows 行 × cols 列”规则排列的大图,按帧索引切出每一帧的源矩形 (SDL_FRect)。 可选 margin(图集四周留白)与 spacing(帧间间隔),单位为像素。
典型用法: Shit::SpriteSheet sheet(4, 8, 32, 32); // 4行8列,每帧32×32 SDL_FRect f = sheet.getFrameRect(5); // 全局第5帧 std::vector<int> walk{0,1,2,3,4,5}; animComp->play("walk", &sheet, walk, 0.1f, true);
| SpriteSheet | ( | int | rows, |
| int | cols, | ||
| float | frameWidth, | ||
| float | frameHeight, | ||
| float | margin = 0.0f, | ||
| float | spacing = 0.0f ) |
构造网格切割参数
| rows | 行数 |
| cols | 列数 |
| frameWidth | 单帧宽(像素) |
| frameHeight | 单帧高(像素) |
| margin | 图集左上角留白(像素,默认 0) |
| spacing | 帧与帧之间的间隔(像素,默认 0) |
|
default |
|
default |
|
defaultnoexcept |
|
inline |
|
inline |
|
inline |
| SDL_FRect getFrameRect | ( | int | frameIndex | ) | const |
全局帧索引(0..rows*cols-1)对应的源矩形
| SDL_FRect getFrameRect | ( | int | row, |
| int | col ) const |
指定行列(0 基)对应的源矩形
|
inline |
|
inline |
|
inline |
|
inline |
|
default |
|
defaultnoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |