Game Development Community

Deleting parent objects?

by Isaac Barbosa · in Torque Game Builder · 01/24/2007 (11:08 am) · 7 replies

Again I can't find an answer to this:

I have a button mounted in a staticsprite, I want to delete both button and the static sprite, but since the button is mounted I dont know how to script that. Is there a way to safeDelete an object making the call from the mounted object? this has to do with parent class? Thanks

#1
01/24/2007 (2:47 pm)
Enable "Owned by Mount" to auto delete mounted objects when parents are deleted.
#2
01/24/2007 (3:26 pm)
Hey Thomas, thanks... I have tried but unsuccessful :( would you be more specific?

I have my square, so I click over it and I want to delete some sprites mounted, but just the square sprite is deleted....
I'm lost.

function square::onAdd(%this)
{
%this.setMountOwned(true);
}
function square::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
activatePackage($currentPackage);
//%this.ownedByMount = true;
%this.safeDelete();

Thanks again
#3
01/24/2007 (3:38 pm)
If I remember well, there is a code snippet to achieve this in the shooter tutorial... I will check it right now :)
#4
01/24/2007 (3:43 pm)
Nop, there is no such function in the scroller tutorial :(
#5
01/24/2007 (4:08 pm)
Oh..just do %this.getObjectParent().safeDelete();
#6
01/24/2007 (4:34 pm)
You mean
%this.getMountedParent().safeDelete();
?

That did the trick! thanks
#7
01/25/2007 (8:46 am)
This

%this.getMountedParent().safeDelete();

and Owned by mount enabled did the trick!

Thanks!