Animations now can have a stationary option which tries to keep them 'in place' while growing, effectively removing the forward motion.
This commit is contained in:
parent
eb8fb82837
commit
8b414c13e6
8 changed files with 36 additions and 15 deletions
|
@ -42,8 +42,10 @@ namespace gui {
|
|||
auto bounds = $boss_image.sprite->getLocalBounds();
|
||||
auto bg_bounds = $boss_background.sprite->getLocalBounds();
|
||||
float x_diff = bg_bounds.size.x / 2;
|
||||
|
||||
$boss_pos = {float(BOSS_VIEW_X) + x_diff, bounds.size.y / 2};
|
||||
$boss_image.sprite->setOrigin({bounds.size.x / 2, bounds.size.y / 2});
|
||||
$boss_image.sprite->setPosition({float(BOSS_VIEW_X) + x_diff, bounds.size.y / 2});
|
||||
$boss_image.sprite->setPosition($boss_pos);
|
||||
}
|
||||
|
||||
void BossFightUI::configure_background() {
|
||||
|
@ -88,9 +90,13 @@ namespace gui {
|
|||
void BossFightUI::bounce_boss(sf::RenderWindow& window) {
|
||||
sf::IntRect frame_rect{{0,0},{$sprite_config.width,$sprite_config.height}};
|
||||
sf::Vector2f scale{$sprite_config.scale, $sprite_config.scale};
|
||||
$animation.step(scale, frame_rect);
|
||||
sf::Vector2f pos{$boss_pos.x, $boss_pos.y};
|
||||
|
||||
$animation.step(scale, pos, frame_rect);
|
||||
$boss_image.sprite->setScale(scale);
|
||||
|
||||
if($animation.stationary) $boss_image.sprite->setPosition(pos);
|
||||
|
||||
if(!sound::playing($sounds.attack) && $animation.current == 1) {
|
||||
sound::play($sounds.attack);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue