Updates to AnimationFrames not respected after first play?
by Cyrus Amiri · in Torque X 2D · 04/23/2007 (9:51 pm) · 2 replies
If I
Construct an T2DAnimatedSprite called mySprite
Fill mySprite.AnimationDataCreate with a new T2DAnimationData
Set mySprite.AnimationData.AnimationFrames to some sequence
Set mySprite.AnimationData.AnimationDuration to some time span
Do an animatedSprite.PlayAnimation() or set PlayOnLoad
I get an animation playing, looking good and happy.
Well, at least for the first animation sequence!
After the first animation plays, if I change the animation frames using mySprite.AnimationData.AnimationFrames = "3 4 5 6" or whatever - it doesn't update!!! The T2DAnimatedSprite *does* seem to respect changes made to the mySprite.AnimationData.AnimationDuration. Is there no way to get the T2DAnimated sprite to invalidate the first animation played? Looking around at code, I notice a lot of people appear to be preload all their unique animations as individual T2DAnimatedSprites, give them unique names, and then "find" them in the Torque database and clone them.
ICKY!
I'd rather just have a T2DAnimated sprite that would respect changes to AnimationFrames!
Hell, it does this for the AnimationDuration. At least there should be some way to get the class to invalidate the animation (I.E invalidate()). Maybe the Torque Guys disabled such functionality because there are some performance concerns with switching back and forth between AnimationFrame sequences. Maybe it costs as much to switch the third time as the first, meaning a preload and Clone() methodology is more effecient.
Or maybe, I just don't know how to invalidate!
As a side note, I did a
TorqueObjectDatabase.Instance.Unregister(mySprite);
TorqueObjectDatabase.Instance.Register(mySprite);
which I thought would have worked as an invalidate, but instead I got an error message saying I was trying to register a already registered object!!
Responses appreciated!
Cyrus the Virus
Construct an T2DAnimatedSprite called mySprite
Fill mySprite.AnimationDataCreate with a new T2DAnimationData
Set mySprite.AnimationData.AnimationFrames to some sequence
Set mySprite.AnimationData.AnimationDuration to some time span
Do an animatedSprite.PlayAnimation() or set PlayOnLoad
I get an animation playing, looking good and happy.
Well, at least for the first animation sequence!
After the first animation plays, if I change the animation frames using mySprite.AnimationData.AnimationFrames = "3 4 5 6" or whatever - it doesn't update!!! The T2DAnimatedSprite *does* seem to respect changes made to the mySprite.AnimationData.AnimationDuration. Is there no way to get the T2DAnimated sprite to invalidate the first animation played? Looking around at code, I notice a lot of people appear to be preload all their unique animations as individual T2DAnimatedSprites, give them unique names, and then "find" them in the Torque database and clone them.
ICKY!
I'd rather just have a T2DAnimated sprite that would respect changes to AnimationFrames!
Hell, it does this for the AnimationDuration. At least there should be some way to get the class to invalidate the animation (I.E invalidate()). Maybe the Torque Guys disabled such functionality because there are some performance concerns with switching back and forth between AnimationFrame sequences. Maybe it costs as much to switch the third time as the first, meaning a preload and Clone() methodology is more effecient.
Or maybe, I just don't know how to invalidate!
As a side note, I did a
TorqueObjectDatabase.Instance.Unregister(mySprite);
TorqueObjectDatabase.Instance.Register(mySprite);
which I thought would have worked as an invalidate, but instead I got an error message saying I was trying to register a already registered object!!
Responses appreciated!
Cyrus the Virus
#2
04/24/2007 (6:24 pm)
Ok, that makes sense, and helps out a lot. Any response to the Register/Unregister error message?
Torque Owner Thomas Buscaglia
That said, you should be able to get the animation data to reload by just manually calling Init() on it and then PlayAnimation() on the sprite. That's not how the system is designed to work, but it should do what you're looking for.
Good luck!