Game Development Community

Animated sprites

by Charles Scholten · in Torque Game Builder · 08/23/2006 (3:59 am) · 4 replies

Hi,

I've created an animated sprite, and when i start the level, the animation sequence is played. I only want the animation to play when the object is clicked on.

How can I prevent the animation from being played when starting the level?

Thanks in advance

a soon to be TGB owner :D

#1
08/23/2006 (5:44 pm)
Charles, when creating the animation in the editor there is a 'Repeat' checkbox, uncheck this box.

call the setUseMouseEvents() method of the object
in the onMouseClick() callback of the object, call the objects playAnimation() method

Hope this helps -- I'd provide code to support this, but have not actually done it yet -- if necessary, I suppose I could whip something up real quick (need to write it eventually anyhow ;p)
#2
08/24/2006 (2:05 am)
Hi David,

Thanks for the reply, but the option 'Repeat' is already unchecked. I can already play the animation by clicking the the sprite.
#3
08/24/2006 (5:23 am)
Set your animation sprite's frame to the last frame on level load.
for instance on the 1234 animation sprite I made it non repeating, and set it to frame 3 (which displays a 4):

function myanimation::onLevelLoaded(%this, %scenegraph)
{
%this.setAnimationFrame(3);
}
#4
08/24/2006 (6:10 am)
Great! That works!! Thanks for the help!