Animations can now be applied to sf::View to do animated camera effects.
This commit is contained in:
parent
d60e1af6df
commit
f1f4cbc80f
4 changed files with 27 additions and 22 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue