2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarDrawable.hpp"
|
|
|
|
#include "StarBiMap.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(Animation);
|
|
|
|
|
|
|
|
class Animation {
|
|
|
|
public:
|
|
|
|
// config can be either a path to a config or a literal config.
|
|
|
|
Animation(Json config = {}, String const& directory = {});
|
|
|
|
|
|
|
|
void setAngle(float angle);
|
|
|
|
|
2023-06-26 06:09:40 +00:00
|
|
|
void setProcessing(DirectivesGroup processing);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
void setColor(Color color);
|
|
|
|
|
|
|
|
void setTag(String tagName, String tagValue);
|
|
|
|
void clearTags();
|
|
|
|
|
|
|
|
Drawable drawable(float pixelSize) const;
|
|
|
|
|
|
|
|
void update(float dt);
|
|
|
|
|
|
|
|
bool isComplete() const;
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum AnimationMode { Stop, EndAndDisappear, LoopForever };
|
|
|
|
static EnumMap<AnimationMode> AnimationModeNames;
|
|
|
|
|
|
|
|
AnimationMode m_mode;
|
|
|
|
String m_directory;
|
|
|
|
String m_base;
|
|
|
|
bool m_appendFrame;
|
|
|
|
int m_frameNumber;
|
|
|
|
float m_animationCycle;
|
|
|
|
float m_animationTime;
|
|
|
|
float m_angle;
|
|
|
|
Vec2F m_offset;
|
|
|
|
bool m_centered;
|
2023-06-26 06:09:40 +00:00
|
|
|
DirectivesGroup m_processing;
|
2023-06-20 04:33:09 +00:00
|
|
|
Color m_color;
|
|
|
|
int m_variantOffset;
|
|
|
|
|
|
|
|
StringMap<String> m_tagValues;
|
|
|
|
int m_frame;
|
|
|
|
float m_animationTimer;
|
|
|
|
float m_timeToLive;
|
|
|
|
bool m_completed;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|