2021-06-23 18:43:13 -04:00
|
|
|
#include "classicdyinganimationscenario.h"
|
2021-12-28 13:04:50 -05:00
|
|
|
#include "graphics/classicsprite.h"
|
2021-06-23 18:43:13 -04:00
|
|
|
|
|
|
|
void ClassicDyingAnimationScenario::launch(const std::shared_ptr<ClassicSprite> sprite, const microsec& time_begin, const microsec &time_end)
|
|
|
|
{
|
|
|
|
_sprite = sprite;
|
|
|
|
_time_begin = time_begin;
|
|
|
|
_time_end = time_end;
|
|
|
|
|
2021-10-04 10:20:24 -04:00
|
|
|
_sprite->setColor(sf::Color(140, 140, 140));
|
|
|
|
_sprite->setTrailColor(sf::Color(0, 0, 0, 0));
|
2021-11-24 13:21:30 -05:00
|
|
|
_sprite->setTrailCoordinates(Coordinates(0, 0));
|
2021-06-23 18:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClassicDyingAnimationScenario::update(const microsec& music_offset)
|
|
|
|
{
|
2021-07-27 14:18:37 -04:00
|
|
|
(void) music_offset;
|
2021-10-04 10:20:24 -04:00
|
|
|
|
|
|
|
auto fill_color = _sprite->color();
|
|
|
|
|
|
|
|
if (fill_color.a == 0)
|
|
|
|
{
|
|
|
|
fill_color.a = 0;
|
|
|
|
_sprite->setColor(fill_color);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto new_alpha = fill_color.a - 15;
|
|
|
|
fill_color.a = new_alpha < 0 ? 0 : new_alpha;
|
|
|
|
|
|
|
|
_sprite->setColor(fill_color);
|
2021-06-23 18:43:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ClassicDyingAnimationScenario::isDone() const
|
|
|
|
{
|
2021-10-04 10:20:24 -04:00
|
|
|
return _sprite->color().a == 0;
|
2021-06-23 18:43:13 -04:00
|
|
|
}
|