Animations can now be applied to sf::View to do animated camera effects.

This commit is contained in:
Zed A. Shaw 2025-11-01 12:29:22 -04:00
parent d60e1af6df
commit f1f4cbc80f
4 changed files with 27 additions and 22 deletions

View file

@ -119,6 +119,22 @@ namespace components {
return playing;
}
bool Animation::apply(sf::View& view_out, sf::Vector2f pos, sf::Vector2f size) {
sf::Vector2f scale{min_x, min_y};
sf::IntRect ignored{{0,0}, {int(size.x), int(size.y)}};
step(scale, pos, ignored);
view_out.setCenter(pos);
if(scaled) {
view_out.setSize({size.x * scale.x, size.y * scale.y});
} else {
view_out.setSize(size);
}
return playing;
}
}
namespace animation {