Animated Tiles in TX2D
by XanthorXIII · in Torque X 2D · 01/27/2010 (8:36 pm) · 3 replies
I think I saw this in another topic but can't seem to find it. Are we able to create animated tiles and if not has anyone come up with code that we can do so with? If not I may need to start lookiing into ways of doing this.
Thanks.
Thanks.
About the author
It's alive!
#2
public class BoardMapComponent : TorqueComponent, IAnimatedObject
Then implement the UpdateAnimation(float dt) method.
All you have to do after that is add your component to the Animation Callback Process List like this:
ProcessList.Instance.AddAnimationCallback(Owner, this);
You can add it to the process list in the OnRegister method or whenever you need to start animating your tiles.
Now all you need are references to T2DTileObject's that contain the frames and you can use the SetTileByGridCoords method to change frames. This is probably not the best way to go about it, but if you have simple tile animations, it should work just fine. I used this method to animate the energizer pills (blink off and on, energizer tile, blank tile) in the pacman remake i'm creating using torqueX.
01/29/2010 (10:04 am)
In order to animate tiles you could create a BoardMapComponent and inherit from the IAnimatedObject interface like this:public class BoardMapComponent : TorqueComponent, IAnimatedObject
Then implement the UpdateAnimation(float dt) method.
All you have to do after that is add your component to the Animation Callback Process List like this:
ProcessList.Instance.AddAnimationCallback(Owner, this);
You can add it to the process list in the OnRegister method or whenever you need to start animating your tiles.
Now all you need are references to T2DTileObject's that contain the frames and you can use the SetTileByGridCoords method to change frames. This is probably not the best way to go about it, but if you have simple tile animations, it should work just fine. I used this method to animate the energizer pills (blink off and on, energizer tile, blank tile) in the pacman remake i'm creating using torqueX.
Torque 3D Owner Henry Shilling
Smokin Skull