OnLevelEnd() ?
by Kevin James · in Torque Game Builder · 04/08/2010 (9:57 am) · 9 replies
What event is triggered here:
sceneWindow2D.endLevel();
Btw, where do I find a listing of all of the available events per class?
sceneWindow2D.endLevel();
Btw, where do I find a listing of all of the available events per class?
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
Also, what event is triggered on sceneobjects when they are deleted? I've tried OnDelete and OnDestroy but the logic never gets there.
04/08/2010 (11:11 am)
Thanks. I'm trying to find the event where it is best to delete objects after the game ends. I can make one, then force a call to it, but this should be an automatic event such as "OnLevelLoad". Also, what event is triggered on sceneobjects when they are deleted? I've tried OnDelete and OnDestroy but the logic never gets there.
#3
Finding callbacks can be kind of confusing because sometimes you need to first look up the type of parent object in the reference, then go to the callbacks section for that type of object.
For instance, a t2dStaticSprite derives from the t2dSceneObject so you go to the t2dSceneObject section, then look at the callbacks.
To find the on delete callback go here. I guess because the callback is fired from the t2dSceneGraph since the object is deleted.
I don't think there is a callback for onLevelEnd... Someone please share if I'm wrong.
04/08/2010 (11:21 am)
Hey Kevin...Finding callbacks can be kind of confusing because sometimes you need to first look up the type of parent object in the reference, then go to the callbacks section for that type of object.
For instance, a t2dStaticSprite derives from the t2dSceneObject so you go to the t2dSceneObject section, then look at the callbacks.
To find the on delete callback go here. I guess because the callback is fired from the t2dSceneGraph since the object is deleted.
I don't think there is a callback for onLevelEnd... Someone please share if I'm wrong.
#4
So far I have this:
I get no errors, but I also never see the echo result in the console. I don't think this code is executed. I might give up on this and go with a more manual approach.
04/08/2010 (11:51 am)
Thanks Patrick, that's exactly what I was looking for.So far I have this:
function SectorLevel::onSafeDelete(%this, %object)
{
// I'm done, now cleanup
echo("..............SectorLevel::onSafeDelete...............");
while(%object.contents.getCount())
%object.contents.getObject(0).safeDelete();
%object.contents.Delete(); //contents is not a sceneobject so just delete
}I get no errors, but I also never see the echo result in the console. I don't think this code is executed. I might give up on this and go with a more manual approach.
#5
04/08/2010 (11:56 am)
EDIT: Sorry, rushed an answer. Going to have to look at this in a little while.
#6
How do you cleanup your objects when the game ends?
Perhaps TGB automatically cleans up everything and I'm wasting my time?
04/08/2010 (12:01 pm)
It boils down to this question:How do you cleanup your objects when the game ends?
Perhaps TGB automatically cleans up everything and I'm wasting my time?
#7
04/08/2010 (12:28 pm)
Search TDN for endLevel().
#8
I can't get the onSafeDelete() callback to fire either. I tried calling it as a class method to t2dSceneGraph, a class of the object being deleted and the item name and no luck. Hopefully someone else can weigh in.
I did a little experiment where I created a bunch of animated sprites rotating around 10 or so objects using the following code... Total maybe 100 in the scene and the memory usage went from 72870 to 78560.
I then called sceneWindow2D.endLevel(); It cleared the scene but the memory stayed exactly the same.
Then I reran it and deleted each of the objects using safeDelete() and the memory once again stayed the same.
Short answer, no idea.
04/08/2010 (5:58 pm)
Kevin,I can't get the onSafeDelete() callback to fire either. I tried calling it as a class method to t2dSceneGraph, a class of the object being deleted and the item name and no luck. Hopefully someone else can weigh in.
I did a little experiment where I created a bunch of animated sprites rotating around 10 or so objects using the following code... Total maybe 100 in the scene and the memory usage went from 72870 to 78560.
I then called sceneWindow2D.endLevel(); It cleared the scene but the memory stayed exactly the same.
Then I reran it and deleted each of the objects using safeDelete() and the memory once again stayed the same.
Short answer, no idea.
#9
04/09/2010 (4:47 am)
Well, that's discouraging. Nevertheless, I'll continue to apply good programming practices and cleanup my objects. Maybe this will be fixed in the next version.
Torque Owner rennie moffat
Renman3000
endLevel()
simply ends level. With no further instructions your game will simply switch to an all black/empty screen.