BUG in T2DAnimationController SetAnimationFrame
by Alex Stittle · in Torque X 2D · 01/28/2010 (12:35 am) · 1 replies
Hey all,
I've found a bug in the T2DAnimationController SetAnimationFrame(uint frame) function. Sometimes it changes your current frame to 1 below what you entered due to, what I think, is a rounding error.
Note that this bug affects T2DAnimatedSprites, since it uses this function.
If you want to see this for yourself, create a 10 frame animation and set the frames per second to be 59.9999. Then, in your code somewhere, set the animation frame to either 5 or 9 and you'll notice that it gets set to 4 and 8 respectively. You can set the frame by using _sprite.SetAnimationFrame(5);
I didn't spend much time debugging (million things to do :)) but I threw a band-aid on the issue by replacing the following in the T2DAnimationController SetAnimationFrame(uint frameIndex) function:
REPLACE:
WITH:
If anyone wants to look into this and find a more elegant solution, go right ahead! Hopefully GG will take a glance and fix this in a future update :)
I've found a bug in the T2DAnimationController SetAnimationFrame(uint frame) function. Sometimes it changes your current frame to 1 below what you entered due to, what I think, is a rounding error.
Note that this bug affects T2DAnimatedSprites, since it uses this function.
If you want to see this for yourself, create a 10 frame animation and set the frames per second to be 59.9999. Then, in your code somewhere, set the animation frame to either 5 or 9 and you'll notice that it gets set to 4 and 8 respectively. You can set the frame by using _sprite.SetAnimationFrame(5);
I didn't spend much time debugging (million things to do :)) but I threw a band-aid on the issue by replacing the following in the T2DAnimationController SetAnimationFrame(uint frameIndex) function:
REPLACE:
// calculate current time _totalTimeElapsed = frameIndex * _frameDuration;
WITH:
// calculate current time _totalTimeElapsed = frameIndex * _frameDuration +(_frameDuration / 1000f); // Add a little time bump to prevent rounding issues
If anyone wants to look into this and find a more elegant solution, go right ahead! Hopefully GG will take a glance and fix this in a future update :)
Associate Tom Spilman
Sickhead Games