Now loading the new animations out of assets/animate2.json

This commit is contained in:
Zed A. Shaw 2026-02-03 00:30:49 -05:00
parent df730047ac
commit dea0607901
7 changed files with 108 additions and 137 deletions

View file

@ -8,11 +8,14 @@
#include <functional>
#include "ease2.hpp"
#include <fmt/core.h>
#include "json_mods.hpp"
namespace animate2 {
template <typename T> struct NameOf;
struct Sheet {
int width{0};
int height{0};
int frames{0};
int frame_width{0};
int frame_height{0};
};
@ -38,7 +41,7 @@ namespace animate2 {
std::vector<std::chrono::milliseconds> durations{};
size_t current{0};
int loop_count{0};
size_t frame_count{frames.size()};
size_t frame_count{0};
Timer timer{};
float subframe{0.0f};
};
@ -82,9 +85,9 @@ namespace animate2 {
class Animate2 {
public:
Sheet $sheet;
Sequence $sequence;
Transform $transform;
Sheet sheet;
Sequence sequence;
Transform transform;
OnFrameHandler onFrame = nullptr;
std::vector<sf::IntRect> $frame_rects{calc_frames()};
@ -101,4 +104,10 @@ namespace animate2 {
std::pair<int, double> commit();
};
Animate2 load(const std::string &file, const std::string &anim_name);
ENROLL_COMPONENT(Sheet, frames, frame_width, frame_height);
ENROLL_COMPONENT(Sequence, frames, durations);
ENROLL_COMPONENT(Transform, min_x, min_y, max_x, max_y, simple, flipped, ease_rate, scaled, toggled, looped);
ENROLL_COMPONENT(Animate2, sheet, sequence, transform);
}