Game Development Community

PickArea()

by Jeremy Tilton · in Torque Game Builder · 03/16/2005 (8:24 pm) · 2 replies

Ok, so for my tetris game, I have gotten to the point to where I declare "Game Over". I splash a game over image up, but now I want to delete all of the objects. Based on my implementaion, I no longer have a variable name to reference all these blocks by, so I figured I'd use pickArea() and delete everything found on the list:

%pickList=t2dSceneGraph.pickArea("-20 -50 20 36", BIT(1)|BIT(2),BIT(1)|BIT(2),false);
    %objCount = getWordCount( %pickList );
    if ( %objCount > 0 )
    {
      for ( %n = 0; %n < %objCount; %n++ )
      {
        %obj = getWord( %pickList, %n  );
        %obj.safeDelete();
      }
    }

Problem is the following error:

fxSceneGraph2D::pickArea - Invalid number of parameters!

I didn't really want to specify layers/groups, but if I just did this:
%pickList=t2dSceneGraph.pickArea("-20 -50 20 36");
I still get the same error.



ARGH!
%pickList=t2dSceneGraph.pickArea("-20 -50", "20 36");
That works..

Thank you Jeremy! Why, you are very welcome Jeremy!



#1
03/16/2005 (8:58 pm)
If you're not concerned about nuking everything in the scene, you could use something like:
t2dSceneGraph.clearScene(true);
to delete everything in the scene graph before putting up the game over image.
#2
03/17/2005 (12:16 am)
As well as Matts suggestion, you can also add stuff to a "SimSet" to keep tabs on your objects, that's what they're typically used for.

When you are ready, iterate the list and "safeDelete()" the whole lot.

- Melv.