Changing a Sprites class. [solved]
by Max Kielland · in Torque Game Builder · 01/18/2013 (1:10 am) · 4 replies
Hi,
Here is a short demo to illustrate the problem:
Everything works fine so far, the sprite is created and the MyActiveClass::onUpdate is called periodically.
But at some point I don't want this sprite to be active and stop to call the onUpdate callback. My thought was that if I remove/change the class it will no longer call MyActiveClass:onUpdate. But it continues to call onUpdate even after I changed the class name.
How do I remove the onUpdate calls for a single sprite?
Here is a short demo to illustrate the problem:
function MyActiveClass::onUpdate(%this) {
// Do stuff
if( ... some logic ...)
%this.class = "";
}
function MyActiveClass::Create() {
%sprite = new t2dStaticSprite()
{
// ...Initialise some params...
class = "MyActiveClass";
};
return %sprite;
}Everything works fine so far, the sprite is created and the MyActiveClass::onUpdate is called periodically.
But at some point I don't want this sprite to be active and stop to call the onUpdate callback. My thought was that if I remove/change the class it will no longer call MyActiveClass:onUpdate. But it continues to call onUpdate even after I changed the class name.
How do I remove the onUpdate calls for a single sprite?
About the author
Owner of MK Development www.mkdevelopment.se
#2
OR if that doesn't work just have your disabling logic skip the rest of the function with something like the 'return;' keyword.
01/18/2013 (6:47 am)
Well you had to turn on the 'onUpdate' callback for each object didn't you? Just have that object turn it off%this.disableUpdateCallback();
OR if that doesn't work just have your disabling logic skip the rest of the function with something like the 'return;' keyword.
#3
You are absolutely right Alpha-Kand! I guess I have been up for to long :P
Thank you both.
01/18/2013 (7:03 am)
Duh!?!You are absolutely right Alpha-Kand! I guess I have been up for to long :P
%this.disableUpdateCallback();Did exactly what I was looking for.
Thank you both.
Torque Owner Richard Ranft
Roostertail Games