Game Development Community

MissionCleanup and delete

by Isidore · in Torque Game Engine · 08/06/2003 (2:37 am) · 1 replies

Hello!

I tested a spell resource the other day, and I met these lines
( I forgot who is the author, but thanks for this :) )

%p = new Explosion() {
  [ datablock... ]
}
MissionCleanup.add(%p);

and
%p = new ParticleEmitterNode() {
  [ datablock... ]
}
%p.schedule(2000,"delete");

What is actually the appropriate way to effectively clean an object when finished with it?

As far as I can see it, the code:
%p.schedule(2000,"delete");
induces a call to the object's destructor after 2 secs, whereas the code:
MissionCleanup.add(%p);
will clean the object when leaving the mission.

Does this make sense or is it completely wrong?

Now, supposing I call
%p.schedule(2000,"delete");
but the exposion is long and is still being rendered at that time, what will happen?
I will try anyway ^^

Thank you by advance for any info.

Cheers,

Isi

#1
08/07/2003 (4:47 am)
I think i have all the answers:
"What is actually the appropriate way to effectively clean an object when finished with it?"
->
MissionCleanup.add(%p); // to delete it when mission ends. it is consequence-free anyway, I think...
%p.schedule(5000,"delete"); // ensures it is deleted after 5 secs

or add a call to
SimObject::deleteObject();
when the object's lifetime is over

as for my other question:
Quote:
but the exposion is long and is still being rendered at that time, what will happen?
the render method won't be called if the object is deleted I guess...

Anyway, consider this thread as closed.

Isi