Game Development Community

How to delete Static Sprites

by Colin Richardson · in Torque Game Builder · 11/11/2006 (1:38 pm) · 5 replies

Hello,

I'm still messing with the Mini Platformer and what i want to be able to do is to place items around that $pGuy can pick up, ie like the Fish Food in that demo.

However i don't want to respawn the Item as they're placed on the level in the designer i would prefer the deleted after they've added the bonus to the player.

How do i do this? I'm used to in other languages etc just deleting/releasing the object but i can't see to find a way to do this.

This is the basic code for the collision of the itemclass and the %this.delete causes an error with the script.

function items::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
if(%dstObj.class $= "playerClass")
{
echo("Let's despawn this");
%this.delete;
}
}


So can anyone point me in the right direction please.

Thanks

#1
11/11/2006 (2:40 pm)
%srcObj will be the item your player has collided with, so you would need to use

%srcObj.safeDelete();
#2
11/12/2006 (2:39 pm)
Hi Gary,

Thanks very much, that worked a treat.

I can't find that Method anywhere in the docs for TGB (TGB Reference.pdf.)

So does anybody know where i can find that Method please.

Thanks again Gary.

Cheers
#3
11/12/2006 (2:59 pm)
Call the dump() function on any object and you can see a list of the functions in that object's namespace.
#4
11/13/2006 (1:53 am)
Hi Ben,

Thanks for that.

But is there not a doc that lists all of this? I was kind of hoping that in the reference folder there would be a doc that listed everything.

Cheers
#5
11/13/2006 (12:30 pm)
TDN has the TGB Reference too (and you can add ones that are missing) - and TGB Reference does have safeDelete().

Please let me know here if there are other methods missing from TGB Reference. I'll add them for the next release.