A bit of refactor to put apply in Animation where it belongs.
This commit is contained in:
parent
102c8c36d5
commit
d60e1af6df
10 changed files with 32 additions and 31 deletions
|
|
@ -102,6 +102,23 @@ namespace components {
|
|||
scale_out.x *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool Animation::apply(sf::Sprite& sprite, sf::Vector2f pos) {
|
||||
sf::IntRect rect{{0,0}, {frame_width, frame_height}};
|
||||
sf::Vector2f scale{min_x, min_y};
|
||||
|
||||
step(scale, pos, rect);
|
||||
|
||||
sprite.setTextureRect(rect);
|
||||
sprite.setPosition(pos);
|
||||
|
||||
// BUG: make this an option: apply_scale, apply_position and ranges for x y
|
||||
if(scaled) {
|
||||
sprite.setScale(scale);
|
||||
}
|
||||
|
||||
return playing;
|
||||
}
|
||||
}
|
||||
|
||||
namespace animation {
|
||||
|
|
@ -111,23 +128,6 @@ namespace animation {
|
|||
static AnimationManager MGR;
|
||||
static bool initialized = false;
|
||||
|
||||
bool apply(Animation& anim, sf::Sprite& sprite, sf::Vector2f pos) {
|
||||
sf::IntRect rect{{0,0}, {anim.frame_width, anim.frame_height}};
|
||||
sf::Vector2f scale{anim.min_x, anim.min_y};
|
||||
|
||||
anim.step(scale, pos, rect);
|
||||
|
||||
sprite.setTextureRect(rect);
|
||||
sprite.setPosition(pos);
|
||||
|
||||
// BUG: make this an option: apply_scale, apply_position and ranges for x y
|
||||
if(anim.scaled) {
|
||||
sprite.setScale(scale);
|
||||
}
|
||||
|
||||
return anim.playing;
|
||||
}
|
||||
|
||||
void rotate(sf::Sprite& target, float degrees) {
|
||||
target.rotate(sf::degrees(degrees));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue