Stopping/resuming animation midway and changing speed
by Shaz · in Torque Game Builder · 08/21/2008 (7:28 pm) · 4 replies
I couldn't find anything helpful on the subject via search or TDN, and the few relevant threads I did turn up give me the horrible feeling it can't be done, but...
Is there a way to make an animation stop or start on a particular frame? Could be the last frame, or could be frame 9 of 15.
Also, is there a way to slow down or speed up the animation? Since they're defined in datablocks, and to my limited knowledge, datablocks contain info that's constant.
Is there a way to make an animation stop or start on a particular frame? Could be the last frame, or could be frame 9 of 15.
Also, is there a way to slow down or speed up the animation? Since they're defined in datablocks, and to my limited knowledge, datablocks contain info that's constant.
About the author
#2
09/03/2008 (8:05 am)
I have the very same problem, I need "stopAnimation()" function in t2dAnimatedSprite class. I can't believe it doesn't have it already, neither I can't believe nobody has answered this thread from 22 august. Perhaps that "very active community" is not for Torque Game Builder and it is just for 3D Torque products... Is very frustrating and dissapointing, expecially when you have paid for it >:(
#3
I created an "idle" animation in the animation builder, as a duplicate of each "moving" animation, then in script, when my player paused, I executed the following (let's assume my animation data blocks are called playerIdleAnimation and playerMovingAnimation respectively, and that $player is a global that points to my t2dAnimatedSprite scene object):
Which effectively determines what frame of the moving animation the player is currently on, then sets the duplicate playerIdleAnimation to ONLY contain that one frame, and makes it the current animation. So it's still looping, but you don't notice.
Having said that however, it appeared that my characters were ALWAYS going into idle state on frame 0 (of 8). So I ended up ditching the first line, and using Animation Builder to make frame 0 the only frame in that animation.
Both solutions work for me. But a stopAnimation() or pauseAnimation() would be really nice to have.
09/03/2008 (8:28 am)
Inaki, my "ugly solution" seems to work ok.I created an "idle" animation in the animation builder, as a duplicate of each "moving" animation, then in script, when my player paused, I executed the following (let's assume my animation data blocks are called playerIdleAnimation and playerMovingAnimation respectively, and that $player is a global that points to my t2dAnimatedSprite scene object):
playerIdleAnimation.animationFrames = $player.getAnimationFrame();
$player.setAnimation("playerIdleAnimation");Which effectively determines what frame of the moving animation the player is currently on, then sets the duplicate playerIdleAnimation to ONLY contain that one frame, and makes it the current animation. So it's still looping, but you don't notice.
Having said that however, it appeared that my characters were ALWAYS going into idle state on frame 0 (of 8). So I ended up ditching the first line, and using Animation Builder to make frame 0 the only frame in that animation.
Both solutions work for me. But a stopAnimation() or pauseAnimation() would be really nice to have.
#4
09/03/2008 (8:34 am)
Yeah, there are workarounds like the ones you post here, but we both agree that the best solution would be a stopAnimation() function (or pause or freeze, etc).
Torque Owner Shaz