8#include <nlohmann/json.hpp>
10#include "galaxy/error/Log.hpp"
11#include "galaxy/scripting/JSON.hpp"
28 this->
m_name = std::move(a.m_name);
30 this->
m_frames = std::move(a.m_frames);
38 this->
m_name = std::move(a.m_name);
40 this->
m_frames = std::move(a.m_frames);
73 auto json = json::read(file);
76 m_name = std::filesystem::path(file).filename().string();
90 for (
const auto& obj : json)
93 .m_bounds = {obj.at(
"x"), obj.at(
"y"), obj.at(
"width"), obj.at(
"height")},
94 .m_duration = obj.at(
"duration")
#define GALAXY_LOG(level, msg,...)
2D animation information.
double m_speed
Speed of the animation. Multiplier, so 1.0f is regular speed.
void prev()
Go back to the previous frame.
bool load(const std::string &file)
Load a json file from VFS and set frames from that.
std::size_t index() const
Get current frame index.
meta::vector< Frame > & frames()
Get the frames.
std::size_t m_index
Index of the current active frame.
Animation & operator=(Animation &&)
Move assignment operator.
void set_frames(const nlohmann::json &json)
Loads frames from json object.
std::string m_name
Animation name.
std::size_t total() const
Get total frames.
void restart()
Sets animation back to beginning.
meta::vector< Frame > m_frames
Frames belonging to this animation.
void next()
Advance to the next frame.
Frame & current()
Get currently active frame.
Single frame of an animation.