Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: thor custom animation  (Read 927 times)

0 Members and 1 Guest are viewing this topic.

Doodlemeat

  • Guest
thor custom animation
« 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);

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: thor custom animation
« Reply #1 on: November 23, 2014, 06:05:13 pm »
Do you call Animator::update() and Animator::animate()?

By the way, there is already thor::FadeAnimation...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Doodlemeat

  • Guest
Re: thor custom animation
« Reply #2 on: November 23, 2014, 08:23:12 pm »
Oh stupid me. Forgot to add animate.

 

anything