载入中...
搜索中...
未找到
SpriteSheet.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <unordered_map>
5#include <vector>
6
7namespace eve::graphics {
8class Quad;
9}
10
11namespace eve::animation {
12
21public:
22 SpriteSheet() = default;
23 ~SpriteSheet() = default;
24
25 SpriteSheet(const SpriteSheet &) = delete;
26 SpriteSheet &operator=(const SpriteSheet &) = delete;
27
29 int addFrame(const std::string &name, int x, int y, int w, int h);
30
36 int setGrid(int columns, int rows, int frameW, int frameH, int margin = 0, int spacing = 0,
37 int originX = 0, int originY = 0);
38
39 void clear();
40
41 int getFrameCount() const { return static_cast<int>(frames_.size()); }
42 int findFrame(const std::string &name) const;
43 std::string getFrameName(int index) const;
44 int getFrameX(int index) const;
45 int getFrameY(int index) const;
46 int getFrameWidth(int index) const;
47 int getFrameHeight(int index) const;
48
50 void applyToQuad(graphics::Quad *quad, int frameIndex) const;
51
52private:
53 struct Frame {
54 std::string name;
55 int x = 0, y = 0, w = 0, h = 0;
56 };
57
58 void checkIndex(int index) const;
59 std::vector<Frame> frames_;
60 std::unordered_map<std::string, int> byName_;
61};
62
63} // namespace eve::animation
int y
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
int h
int w
const char * name
Definition RockMesh.cpp:21
int spacing
int columns
int margin
Sprite-sheet / texture-atlas frame table (pixel rects).
Definition SpriteSheet.h:20
int getFrameX(int index) const
SpriteSheet(const SpriteSheet &)=delete
int addFrame(const std::string &name, int x, int y, int w, int h)
Append a named frame. Returns frame index. Empty name → "frameN".
int setGrid(int columns, int rows, int frameW, int frameH, int margin=0, int spacing=0, int originX=0, int originY=0)
Generate frames in row-major order from a grid. frameW/frameH are cell sizes; margin is outer padding...
std::string getFrameName(int index) const
int getFrameWidth(int index) const
SpriteSheet & operator=(const SpriteSheet &)=delete
int getFrameHeight(int index) const
int getFrameY(int index) const
int findFrame(const std::string &name) const
void applyToQuad(graphics::Quad *quad, int frameIndex) const
Write pixel viewport into an existing Quad (does not allocate).
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:9
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6