Game Development Community

Clear Screen of all spawned Spawner Objects

by Stuart Walton · in Torque X 2D · 05/08/2008 (1:29 pm) · 3 replies

Is there a command that will destroy all sprites on the screen that have been spawned from a Spawner Object.

So if the player dies all enemies on the screen disapear, I know the SpaceShooter game does this but the code varies significantly to the code i based my game on from the defender tutorial.

#1
05/08/2008 (4:07 pm)
Look at the microbes tutorial, you can search the entire scene graph for objects of a specific type. If all your enemys are of the same type, you can kill them all in one sweep, or search for all types within the defined radius and delete all the ones that match your criteria, whatever they are.

Will-O
#2
05/08/2008 (4:09 pm)
Cheers :)

Dam Microbes is only tutorial i havent looked at :/
#3
05/10/2008 (2:14 pm)
Before you start the level you can set a folder that all registered object will be stored in. Then when you want to unregister all of those objects, you can just unregister the folder.

TorqueFolder levelFolder = new TorqueFolder ();
TorqueObjectDatabase.Instance.Register(levelFolder );
TorqueObjectDatabase.Instance.CurrentFolder = levelFolder ;

Then, after your level is over I think just do:

TorqueObjectDatabase.Instance.Unregister(levelFolder);

and all your objects should be unregistered.

Side note: If you have components that are listening to an event then I think you have to set them to silence those events in the components UnRegister method, or else the obejct will still receive events even though it was unregistered.