Game Development Community

OnFrameChange callback (behaviors)

by Phillip O'Shea · in Torque Game Builder · 01/06/2008 (7:44 pm) · 3 replies

I have noticed that the "onFrameChange" callback doesn't get called for a behavior attached to a t2dAnimatedSprite.

I can just get around it by changing the class from my behavior name to "t2dSceneObject", but it would be nice to have it use the behavior's class.

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
02/04/2008 (2:50 am)
I found that if you have a callback which does not work for a behavior, you can just create an empty callback function of the same type for your object's class and it will allow the behavior's callback to work. For example:

function MyBehavior::onFrameChange(%this, %frame)
{
   echo ("Here yet?");
}

This will result in nothing being echoed, however when we add the following function, the above will work!

function t2dAnimatedSprite::onFrameChange(%this, %frame)
{
   // Nothing to see here folks
}
#2
09/21/2009 (1:02 pm)
So where would you put this Phillip as I am having trouble with linking an animation within a behavior. would you create a player class then link it somehow to the behavior (in particular Y velocities)?
#3
09/21/2009 (1:10 pm)
Interesting find Phillip. I haven't tried duplicating this yet but I'd suspect it to be a bug, as you shouldn't need to make a dummy function in order to get the original behaviors function to be called.