SFML community forums

Help => General => Topic started by: Doodlemeat on November 23, 2014, 05:57:27 pm

Title: thor custom animation
Post by: Doodlemeat on November 23, 2014, 05:57:27 pm
Hello.

I am using the animation system from the thor library and I have problems making a fade animation.
I got this sprite in a class together with a thor::animator<sf::sprite, std::string>. The problem is when I create the connection between the animator and the fade function. As you can see I print output to the console just to see if I am in there but I never get there. Do you know why? Is my bind correct?

        m_animator.addAnimation("fade", std::bind(&LightningBolt::fade, this, std::placeholders::_1, std::placeholders::_2), m_fadeDuration);

And here is the method:
void fade(sf::Sprite& animated, float progress)
        {
                printf("progress %f", progress);
                int alpha = int((1.f - progress) * 255.f);
                animated.setColor(sf::Color(255, 255, 255, alpha));
                if (alpha == 0)
                {
                        m_canDie = true;
                }
        }

And I start it like this:
                        m_animator.playAnimation("fade", false);
Title: Re: thor custom animation
Post by: Nexus on November 23, 2014, 06:05:13 pm
Do you call Animator::update() and Animator::animate()?

By the way, there is already thor::FadeAnimation...
Title: Re: thor custom animation
Post by: Doodlemeat on November 23, 2014, 08:23:12 pm
Oh stupid me. Forgot to add animate.