载入中...
搜索中...
未找到
SpriteClip.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <vector>
5
6namespace eve::animation {
7
8class SpriteSheet;
9
15public:
16 explicit SpriteClip(const std::string &name = "");
17 ~SpriteClip() = default;
18
19 SpriteClip(const SpriteClip &) = delete;
20 SpriteClip &operator=(const SpriteClip &) = delete;
21
22 void setName(const std::string &name);
23 std::string getName() const { return name_; }
24
25 void setLoop(bool loop) { loop_ = loop; }
26 bool getLoop() const { return loop_; }
27
29 void addFrame(int sheetFrameIndex, float duration = 0.1f);
30
32 void addFrameByName(SpriteSheet *sheet, const std::string &frameName, float duration = 0.1f);
33
34 void clear();
35
36 int getFrameCount() const { return static_cast<int>(frames_.size()); }
37 int getSheetFrame(int index) const;
38 float getFrameDuration(int index) const;
39 float getDuration() const;
40
45 int frameAtTime(float timeSeconds) const;
46
48 float wrapTime(float timeSeconds) const;
49
50private:
51 struct Entry {
52 int sheetFrame = 0;
53 float duration = 0.1f;
54 };
55
56 void checkIndex(int index) const;
57
58 std::string name_;
59 bool loop_ = true;
60 std::vector<Entry> frames_;
61};
62
63} // namespace eve::animation
const char * name
Definition RockMesh.cpp:21
Named 2D frame sequence referencing SpriteSheet frame indices. Script type: SpriteClip.
Definition SpriteClip.h:14
SpriteClip(const SpriteClip &)=delete
int getSheetFrame(int index) const
float wrapTime(float timeSeconds) const
Local time wrapped or clamped according to loop flag.
std::string getName() const
Definition SpriteClip.h:23
void addFrame(int sheetFrameIndex, float duration=0.1f)
Append one cell: sheetFrameIndex + display duration (seconds).
void setName(const std::string &name)
void addFrameByName(SpriteSheet *sheet, const std::string &frameName, float duration=0.1f)
Resolve name via sheet and append.
void setLoop(bool loop)
Definition SpriteClip.h:25
int frameAtTime(float timeSeconds) const
Map absolute time (seconds) into a clip frame index. When loop is false and t >= duration,...
SpriteClip & operator=(const SpriteClip &)=delete
float getFrameDuration(int index) const
Sprite-sheet / texture-atlas frame table (pixel rects).
Definition SpriteSheet.h:20