![]() |
ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
|
逐帧动画数据 更多...
#include <Animation.h>
Public 成员函数 | |
| Animation (float duration=0.1f, bool loop=true) | |
| ~Animation () | |
| void | addFrame (const AnimFrame &frame) |
| 添加单帧(带纹理路径) | |
| void | addFrame (const Rect &rect) |
| 兼容:空路径(沿用当前纹理,动态 play API 用) | |
| void | addFrames (const std::vector< Rect > &frames) |
| 批量添加(空路径,兼容) | |
| void | setFrameDurations (const std::vector< float > &durations) |
| 设置每帧独立时长(秒)。传入空 → 回退到统一 duration;传入长度须等于帧数。 | |
| void | clearFrameDurations () |
| 清除每帧独立时长,回退到统一 duration | |
| AnimFrame | getFrame (float elapsedTime) const |
| 根据已播放时间返回当前帧(纹理+矩形) | |
| void | setLoop (bool loop) |
| void | setDuration (float duration) |
| bool | isLooping () const |
| float | getDuration () const |
| float | getTotalDuration () const |
| 总时长(秒):有逐帧时长则累加,否则 frameCount × duration | |
| float | getFrameDuration (int i) const |
| 取第 i 帧的时长(秒):逐帧存在用逐帧值,否则统一 duration | |
| int | getFrameCount () const |
逐帧动画数据
存储一组帧(AnimFrame:纹理路径 + 源矩形)及每帧持续时间。 getFrame(elapsedTime) 根据当前播放时间返回对应帧。 通常由 AnimationComponent 自动管理,不直接使用。
| Animation | ( | float | duration = 0.1f, |
| bool | loop = true ) |
| ~Animation | ( | ) |
| void addFrame | ( | const AnimFrame & | frame | ) |
添加单帧(带纹理路径)
| void addFrame | ( | const Rect & | rect | ) |
兼容:空路径(沿用当前纹理,动态 play API 用)
| void addFrames | ( | const std::vector< Rect > & | frames | ) |
批量添加(空路径,兼容)
|
inline |
清除每帧独立时长,回退到统一 duration
|
inline |
| AnimFrame getFrame | ( | float | elapsedTime | ) | const |
根据已播放时间返回当前帧(纹理+矩形)
|
inline |
| float getFrameDuration | ( | int | i | ) | const |
取第 i 帧的时长(秒):逐帧存在用逐帧值,否则统一 duration
| float getTotalDuration | ( | ) | const |
总时长(秒):有逐帧时长则累加,否则 frameCount × duration
|
inline |
|
inline |
|
inline |
设置每帧独立时长(秒)。传入空 → 回退到统一 duration;传入长度须等于帧数。
|
inline |