Game Development Community

T2dSceneObjectGroup Bug?

by David Higgins · in Torque Game Builder · 11/08/2006 (7:23 pm) · 1 replies

I am using the t2dSceneObjectGroup and I think I've stumbled across a bug, or an undocumented oddity -- although, the t2dSceneObjectGroup is undocumented to begin with :)

Here is a sample;

function myObject::create(%param1, %param2)
{
   %obj = new t2dSceneObjectGroup()
   {
      canSaveDynamicFields = "1";
      class = "myObject";
      superclass = "objectBaseClass";
      Type = %type;
   };

   %s = new t2dStaticSprite()
      {
         config = myDataBlock;
         imageMap = myImageMap;
         frame = %param2;
         blendingEnabled = 1;
         Tag = "myType";
      };
      %obj.add(%s);
}

When I call the myObject::create() method for the first time in a freshly started TGB instance -- I get the following errors:

project/gameScripts/script.cs (XX): Unknown command add.
  Object [2712] myClass1 -> myClass2 -> t2dSceneObjectGroup -> t2dSCeneObjectSet -> SimSet -> SimObject

When I debug, isObject(%obj) is true, but yet %obj.dump() and %obj.dumpClassHierarchy() both return the 'Unknown command' error stated above.

If I hit ESC and return to the level builder, then hit F5 to run the level once more -- everything works as expected.

I am executing the code after the level is loaded -- as such:

function startGame(%level)
{
   // Set The GUI.
   Canvas.setContent(mainScreenGui);
   Canvas.setCursor(DefaultCursor);
   
   moveMap.push();
   
   if( isFile( %level ) || isFile( %level @ ".dso"))
      sceneWindow2D.loadLevel(%level);
      
   exec("./script.cs");
   exec("./test.cs");
}

The code exists in the script.cs, and the objectModel::create() is performed in the test.cs ...

script.cs is just a series of additional exec() commands, which exec's all my necessary scripts ... all in the proper order ... though that is the part I am debugging now, to ensure it's the correct order -- though I'm 99.9% positive it is -- so I'm posting here for additional input ...

Thanks in advance for any insight to this problem --

#1
11/08/2006 (7:55 pm)
UPDATE: Found the problem -- apparently, I'm using the objectModel::create() as a 'static' method -- but since it's creating an object that uses the same 'class', it seems to have some sort of issue with that -- not quite sure why it works if I ESC and re-load the level again from the level builder -- but the solution I found that works is:

function myObject::create(...)

get's turned into:

function myObjectCreate(...)


Now it's a stand-alone function -- problem is, I don't like this -- so if anyone has a solution, let me know.