Game Development Community

Can't spawn through script?

by Tyler Slabinski · in iTorque 2D · 11/28/2010 (3:25 am) · 1 replies

I've been trying to spawn a simple static sprite through script, but I don't seem to be able to do that.

BlockSpawn.cs
function createBlock()
{
	echo("Creating Block");
   new t2dStaticSprite() {
      imageMap = "BlockImageMap";
      frame = "0";
      mUseSourceRect = "0";
      sourceRect = "0 0 0 0";
      canSaveDynamicFields = "1";
	  Position = "-2.538 -37.064";
      size = "32.000 32.000";
      CollisionMaxIterations = "3";
         mountID = "2";
   };
}

createBlock();

I don't get any error in the console, so I don't know what's wrong. This seems to work in TGB, but iTGB doesn't seem to like me very much...

#1
11/28/2010 (5:07 am)
You need to add it to a scene graph.

SceneGraph = $SceneWindow.getScenegraph();