0
\$\begingroup\$

I'm having a small issue with libgdx animation.

I'm using getKeyFrame() to get the current frame of the animation and I'm updating the state time by adding on deltaTime in my update function for the object. The animation is not looping.

My problem is that the animation seems to play at different speeds depending on the frame rate. On my phone this animation plays particularly slow. My thinking was that the stateTime would cause it to skip a few frames when it's going slow, but this doesn't seem to be happening.

Here is the code;

        sprite = Animation.getKeyFrame(stateTime, false);
        sprite.setRotation(angle);
        sprite.setPosition(position.x, position.y);
        sprite.draw(batch);

Has anyone else experience this issue.

\$\endgroup\$
5
  • \$\begingroup\$ Maybe your delta time is wrong? \$\endgroup\$ Commented Apr 27, 2012 at 19:01
  • \$\begingroup\$ The delta time seems fine. I tried doing stateTime * 100000 and that made no difference and I have changed the animation time with no difference. \$\endgroup\$ Commented Apr 28, 2012 at 1:20
  • \$\begingroup\$ Maybe a bug in libgdx, then... \$\endgroup\$ Commented Apr 29, 2012 at 15:55
  • \$\begingroup\$ I'm hoping to spend some more time this week trying to find out if that's the case. I was just hoping that someone else had run into it at some point. \$\endgroup\$ Commented Apr 29, 2012 at 18:10
  • \$\begingroup\$ Based om depresscreate's answer, you may just need to upgrade to 0.9.3 \$\endgroup\$
    – ashes999
    Commented May 1, 2012 at 21:18

2 Answers 2

1
\$\begingroup\$

I;ve tested it and it seems to work ok on libgdx 0.9.3... Can it be some problem with the way you generate "stateTime"? I would also look in the frameDuration argument that the Animation constructor get.

\$\endgroup\$
2
  • \$\begingroup\$ The frame duration is 0.66f I think. But I don't think it's that because I would still expect the animation to play at the same rate on all devices. I'll try upgrading to 0.9.3. I thought I had done that, but it was very late so I'll try again. \$\endgroup\$ Commented May 1, 2012 at 22:35
  • \$\begingroup\$ I updated to 0.9.3 and everything seems to be working. So I think I had an old version of the library, but I did do a bit of cleaning up of the code as well, so I can't say that definitively. \$\endgroup\$ Commented May 2, 2012 at 22:52
0
\$\begingroup\$

Check this: getKeyFrame

sprite = Animation.getKeyFrame(stateTime, true);

Animation seems to play at different speeds depending on the frame rate. Can you verify if your game runs at 60fps or 30fps? I also recommend you look for information about "frame skip".

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .