Game Development Community

Animation from Button Press

by Sean T. Boyette · in Torque X 2D · 05/11/2007 (10:15 pm) · 0 replies

I am intersted in playing an animation on button press... and then returing to an animation when that is completed.

My current process..
Create the animations in TGBX, the name is: Alex_Stance
Drag him on the canvas
Add movement compnent to the character, name him Alex
Create the animations in TGBX, the name is: Alex_WalkFAnimation
Drag him on the canvas - and name him: WalkFAnimation

in ProcessTick I add:
if (move.Buttons[0].Pushed)
_WalkF();
create a method called
void _WalkF()
{
T2DAnimatedSprite tWalkFAnimation = (T2DAnimatedSprite)(TorqueObjectDatabase.Instance.FindObject("WalkFAnimation") as T2DAnimatedSprite).Clone();
(Owner as T2DAnimatedSprite).Material = tWalkFAnimation.Material;
}

This changes the animation - material, but the sprite is all messed up, it seems to be flipping vertically.

Any ideas?