OnAnimationEnd()
by Gellyware · in Torque Game Builder · 03/22/2008 (4:08 pm) · 5 replies
What is required to get the onAnimationEnd(%this) callback to work?
I can not get the function to call by using the setAnimation or playAnimation functions.
Any suggestions?
I can not get the function to call by using the setAnimation or playAnimation functions.
Any suggestions?
About the author
#2
Here is the code used:
The echo is never called.
03/22/2008 (4:29 pm)
Hi Phillip, thanks for the quick response. The animation is not part of a behavior and it seems to be looping.Here is the code used:
function bossFrog::setState(%this, %state)
{
%this.state = %state;
switch$( %state )
{
case "idle":
%this.playAnimation("BossFrogIdleOutlinedAnimation");
case "laugh":
%this.playAnimation("BossFrogLaughOutlinedAnimation");
case "cast":
%this.playAnimation("BossFrogCastOutlinedAnimation");
case "die":
%this.playAnimation("BossFrogDieOutlinedAnimation");
}
}
function bossFrog::onAnimationEnd(%this)
{
//onAnimationEnd(%this)
echo("--->> ANIMATION ENDED <<---");
if(%this.state $= "idle")
%this.setState("idle");
if(%this.state $= "cast")
%this.setState("idle");
}The echo is never called.
#3
03/22/2008 (4:34 pm)
If an animation loops, it will never end, thus no callback ;)
#4
Didn't even think to try that. I'll give it a try now.
Thanks Phillip, you're helpful as always.
03/22/2008 (4:40 pm)
Well that makes a lot of sense!!! Didn't even think to try that. I'll give it a try now.
Thanks Phillip, you're helpful as always.
#5
You could use an onFrameChange callback to check if the frame currently playing is the last frame in your looping animation.
03/22/2008 (6:07 pm)
Phil is the man. ;DYou could use an onFrameChange callback to check if the frame currently playing is the last frame in your looping animation.
Associate Phillip O'Shea
Violent Tulip
Secondly, are you using it as part of a behavior? If so, try adding this to your code, anywhere will do:
function t2dAnimatedSprite::onAnimationEnd(%this) { // Nothing here }I did this to fix the onFrameChange callback.