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

逐帧动画数据 更多...

#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()

Animation ( float duration = 0.1f,
bool loop = true )

◆ ~Animation()

~Animation ( )

成员函数说明

◆ addFrame() [1/2]

void addFrame ( const AnimFrame & frame)

添加单帧(带纹理路径)

◆ addFrame() [2/2]

void addFrame ( const Rect & rect)

兼容:空路径(沿用当前纹理,动态 play API 用)

◆ addFrames()

void addFrames ( const std::vector< Rect > & frames)

批量添加(空路径,兼容)

◆ clearFrameDurations()

void clearFrameDurations ( )
inline

清除每帧独立时长,回退到统一 duration

◆ getDuration()

float getDuration ( ) const
inline

◆ getFrame()

AnimFrame getFrame ( float elapsedTime) const

根据已播放时间返回当前帧(纹理+矩形)

◆ getFrameCount()

int getFrameCount ( ) const
inline

◆ getFrameDuration()

float getFrameDuration ( int i) const

取第 i 帧的时长(秒):逐帧存在用逐帧值,否则统一 duration

◆ getTotalDuration()

float getTotalDuration ( ) const

总时长(秒):有逐帧时长则累加,否则 frameCount × duration

◆ isLooping()

bool isLooping ( ) const
inline

◆ setDuration()

void setDuration ( float duration)
inline

◆ setFrameDurations()

void setFrameDurations ( const std::vector< float > & durations)
inline

设置每帧独立时长(秒)。传入空 → 回退到统一 duration;传入长度须等于帧数。

◆ setLoop()

void setLoop ( bool loop)
inline

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