Game Development Community

T2dSceneObjectSet

by Playware · in Torque Game Builder · 04/05/2007 (1:12 am) · 1 replies

Hi,
while playing around with the level builder and the codes, and reading the references, i realised that there is another object derived from t2dSceneObjectGroup, "t2dSceneObjectSet". that really interests me due to the functions it offers (according to the reference) but a few issues in my mind:

1) is t2dSceneObjectSet supported in the current build or later version?
2) if it is really supported, how do i instantiate it??

thanks :-)

#1
04/07/2007 (7:27 am)
t2dSceneObjectSet allows you to apply settings to all scene objects in the set simultaneously offset from the set mid point. This allows you to e.g. call %objectSet.setPositionX() and all scene objects in the set will move to the new position offset by their intra-set positions, or %objectSet.rotate() which will rotate all scene objects in the set around the set mid point. I think it is still under construction as basic interface methods like setPosition() have not been declared as console methods yet, etc. Here is an example that you can try to see the effect. Change the image map name in addSprite() to whatever you have. It places 5 sprites in a cross and rotates all of them using the object set:

function TestApp::addSprite( %this, %x, %y )
{
   %s = new t2dStaticSprite()
   { 
      scenegraph = %this.os.scenegraph; 
      imageMap = "orcImageMap"; 
      frame = 0;  
   };
      
   %s.setPosition( %x, %y );
      
   %this.os.add( %s );
}

function TestApp::onAdd( %this )
{
   %sg = sceneWindow2D.getSceneGraph();
   
   %this.os = new t2dSceneObjectSet()
   {
      scenegraph = %sg;
   };
   
   %this.addSprite( 0, 0 );
   %this.addSprite( -20, 0 );
   %this.addSprite(  20, 0 );
   %this.addSprite( 0, -20 );
   %this.addSprite( 0, 20 );
   
   %this.sg = %sg;

   %this.os.setRotation( 45 );
}

$app = new ScriptObject()
{
   class = "TestApp";
};