You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/modes/classicmode/graphics/animations/classicdyinganimationscenar...

38 lines
942 B
C++

#include "classicdyinganimationscenario.h"
#include "graphics/classicsprite.h"
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;
_sprite->setColor(sf::Color(140, 140, 140));
_sprite->setTrailColor(sf::Color(0, 0, 0, 0));
_sprite->setTrailCoordinates(Coordinates(0, 0));
}
void ClassicDyingAnimationScenario::update(const microsec& music_offset)
{
(void) music_offset;
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);
}
bool ClassicDyingAnimationScenario::isDone() const
{
return _sprite->color().a == 0;
}