Sound is now working, and the animator tools will play them and also has mute.

This commit is contained in:
Zed A. Shaw 2026-02-06 13:39:34 -05:00
parent a4ffacdb18
commit 46f34828e4
5 changed files with 38 additions and 19 deletions

View file

@ -52,7 +52,6 @@ namespace animate2 {
float min_y{1.0f};
float max_x{1.0f};
float max_y{1.0f};
bool simple{true};
bool flipped{false};
float ease_rate{0.5f};
bool scaled{false};
@ -87,6 +86,7 @@ namespace animate2 {
}
using Form = std::pair<std::string, std::string>;
using Sound = std::pair<size_t, std::string>;
class Animate2 {
public:
@ -94,6 +94,7 @@ namespace animate2 {
std::unordered_map<std::string, Sequence> sequences;
std::unordered_map<std::string, Transform> transforms;
std::unordered_map<std::string, Form> forms;
std::unordered_map<std::string, std::vector<Sound>> sounds;
OnFrameHandler onFrame = nullptr;
Sequence sequence{};
@ -110,6 +111,7 @@ namespace animate2 {
std::vector<sf::IntRect> calc_frames();
void play();
void play_sound();
void stop();
void set_form(const std::string& form);
void apply(sf::Sprite& sprite);
@ -123,7 +125,7 @@ namespace animate2 {
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,
ENROLL_COMPONENT(Transform, min_x, min_y, max_x, max_y,
flipped, ease_rate, scaled, toggled, looped, easing, motion);
ENROLL_COMPONENT(Animate2, sheet, sequences, transforms, forms);
ENROLL_COMPONENT(Animate2, sheet, sequences, transforms, forms, sounds);
}