Game Development Community

Pausing t2dAnimatedSprites

by WesTT · in Torque Game Builder · 01/07/2008 (11:10 pm) · 4 replies

This is possibly a stupid question ;) but I really can not find an *easy* way to pause an animation from playing once it has been set with setAnimation of playAnimation. Why do I want to do this? I have an "animation" I potentially want to play frame-by-frame when something impacts it, that is, one frame per collision. I cannot use setAnimationFrame to do this if I cannot pause the animation. There is the onFrameChange callback of course, but this seems like a kludge. I've looked at the C++ code and there appears to be no pause function.

Any ideas? Have a missed something? :)

#1
01/07/2008 (11:58 pm)
Could you set the FPS on the animation datablock to 0? I've never tried it, however.
#2
01/08/2008 (12:13 am)
Hi Phillip!

I tried that, it sets it back to 1 automaticlly. I checked the code and this is the animation builders lower bound.

EDIT: And I should say: I tried changing it directly in the datablock too, no luck. The animation controller will spit out an error message in that instance.

Thanks anyway.
#3
01/08/2008 (1:18 am)
Maybe you could something using getAnimationFrame() and setAnimationFrame(%frame).
#4
01/08/2008 (1:36 am)
Hi Benjamin,

Sure, the idea was to simply pause the animation then use those methods. However, I don't really see the point in having two sources trying to update the same animation (the animation controller, and my behavior). it would probably work with onFrameChanged but I also have quite a few sprites on screen at a time. They have fairly few frames of animation, but it could get expensive doing it that way.

The other way I figured I could do it is simply make seperate animations with a single frame, that seems like such an excess for such a simple feature though. I think the t2dAnimatedSprite class really needs to expose more control to the user, or allow us to create our own animation controllers. Of course, I would have perhaps used a straight t2dImageMap if I knew this would be a problem.

Cheers