Game Development Community

SetAnimationFrame problems

by Arden · in Torque X 2D · 01/27/2011 (5:31 pm) · 2 replies

Hiya All, not sure if some of you have some experience with this, but when I'm setting the animation frame manually, like in:

AnimatedDestructibleObject.SetAnimationFrame(1);

Sometimes frames will be skipped, and be unavailable.
For instance, I have an animation using 11 frames, the last one being the building being destroyed.
Frames 5 and 10 (starting from index 0) are being skipped all the time.

This is really frustrating, and I have spent hours remaking my animations and looking at the frames to no avail.

Any ideas to what could be causing this?
Thanks,

Jeff

#1
01/27/2011 (5:46 pm)
Yes, this happened to me before... the set frame code is kind of wonky, if you look at what it does. Best thing to do is change how much time is between frames, or rewrite the set frame code. I usually set it to 1 second per frame.
#2
01/27/2011 (5:56 pm)
Yea, I came to the same conclusion as you; I basically started to update it as part of the ProcessTick and created a function:

public void UpdateAnimationFrame (float aDeltaTime)
        {
            if (System.Environment.TickCount - lastTick >= GuiTextUtils.Instance.timeSecInteval)
            {
                AnimatedDestructibleObject.SetAnimationFrame(CurrentAnimationFrame);
                lastTick = System.Environment.TickCount;
            }
        }

Cheers!