bignic

I ripped through a simple OpenGL runtime from the SFML example and got everything working except the animation, which is playing backwards.

Looking at the original source, I'm confused as to what the 2nd parameter to animation.apply() is supposed to be? It appears to just take a float representing seconds passed since animation start, but the way the code goes about doing that seems needlessly complex?
float delta = deltaClock.getElapsedTime().asSeconds();
deltaClock.restart();
animationTime += delta;

animation->apply(skeleton, animationTime, true);
If I understand this correctly, we get the elapsed time since the last frame, restart our timer, and then add that elapsed time to our animationTime variable. Then we send it to animate->apply().

Isn't that the same as sending getElapsedTime() in, without ever resetting the clock?

I know I'm missing something here, because when I try to do just that in my own code, poor SpineBoy only walks backwards...
bignic
  • Postovi: 14

Nate

That code for the deltaClock is how SFML works when you want to get the time since last frame. It is accumulated in animationTime because that is typically how you would do it. You probably have many animations and would track the time for each rather than use an sf::Clock for each.
Avatar
Nate

Nate
  • Postovi: 11875

bignic

But animation.apply() does expect an incrementing float counter with the elapsed seconds since animation start?

Spine boy, y u walk backwards?!

EDIT:
Because I was sending it milliseconds since app start, not seconds ;) ... its the little things...
bignic
  • Postovi: 14

Nate

:rofl:
Avatar
Nate

Nate
  • Postovi: 11875


Natrag na Editor