Sorted out the animation vs. easing contradiction I believe. Now there's a separate easing_duration that's calculated from the total duration of all frames. Then a easing_position determines where in the total the animation is, which is fed to the asing functions as a ration of easing_position / easing_duration.
This commit is contained in:
parent
0c798c9e0d
commit
1baca783fc
9 changed files with 47 additions and 75 deletions
11
animate2.hpp
11
animate2.hpp
|
|
@ -29,6 +29,7 @@ namespace animate2 {
|
|||
double current_time = 0.0;
|
||||
double frame_duration = 0.0;
|
||||
double alpha = 0.0;
|
||||
int elapsed_ticks = 0;
|
||||
sf::Clock clock{};
|
||||
|
||||
std::pair<int, double> commit();
|
||||
|
|
@ -40,12 +41,14 @@ namespace animate2 {
|
|||
|
||||
struct Sequence {
|
||||
std::vector<int> frames{};
|
||||
std::vector<std::chrono::milliseconds> durations{};
|
||||
std::vector<int> durations{}; // in ticks
|
||||
size_t current{0};
|
||||
int loop_count{0};
|
||||
size_t frame_count{0};
|
||||
Timer timer{};
|
||||
float subframe{0.0f};
|
||||
int subframe{0};
|
||||
float easing_duration{0.0f};
|
||||
float easing_position{0.0f};
|
||||
};
|
||||
|
||||
struct Transform {
|
||||
|
|
@ -55,7 +58,6 @@ namespace animate2 {
|
|||
float max_x{1.0f};
|
||||
float max_y{1.0f};
|
||||
bool flipped{false};
|
||||
float ease_rate{0.5f};
|
||||
bool scaled{false};
|
||||
bool relative{false};
|
||||
|
||||
|
|
@ -123,7 +125,6 @@ namespace animate2 {
|
|||
void update();
|
||||
void motion(sf::Transformable& sprite, sf::Vector2f pos, sf::Vector2f scale);
|
||||
void motion(sf::View& view_out, sf::Vector2f pos, sf::Vector2f scale);
|
||||
std::pair<int, double> commit();
|
||||
};
|
||||
|
||||
Animate2 load(const std::string &file, const std::string &anim_name);
|
||||
|
|
@ -131,6 +132,6 @@ 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,
|
||||
flipped, ease_rate, scaled, relative, toggled, looped, easing, motion);
|
||||
flipped, scaled, relative, toggled, looped, easing, motion);
|
||||
ENROLL_COMPONENT(Animate2, sheet, sequences, transforms, forms, sounds);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue