Trouble spawning objects
by Chris Vallance · in Torque Game Builder · 04/13/2006 (12:18 am) · 0 replies
I'm trying to make a function that will spawn script objects in different locations, depending on a "class" designation found in the object description. Think "Missile Command". Hit 3 different buttons to fire similar projectiles from 3 different bases.
My code looks something like this:
%eval = "%obj = new t2dStaticSprite(" @ %name SPC ":" SPC %type @ ") { sceneGraph = t2dScene; };";
eval(%eval);
// set the position of the object
if ( %obj.class = "one" )
%obj.setPosition( BaseOne.getPositionX(), BaseOne.getPositionY() );
if ( %obj.class = "two" )
%obj.setPosition( BaseTwo.getPositionX(), BaseTwo.getPositionY() );
if ( %obj.class = "three" )
%obj.setPosition( BaseThree.getPositionX(), BaseThree.getPositionY() );
No matter what I try, all my objects spawn at the same location.
Any idea what I am doing wrong?
My code looks something like this:
%eval = "%obj = new t2dStaticSprite(" @ %name SPC ":" SPC %type @ ") { sceneGraph = t2dScene; };";
eval(%eval);
// set the position of the object
if ( %obj.class = "one" )
%obj.setPosition( BaseOne.getPositionX(), BaseOne.getPositionY() );
if ( %obj.class = "two" )
%obj.setPosition( BaseTwo.getPositionX(), BaseTwo.getPositionY() );
if ( %obj.class = "three" )
%obj.setPosition( BaseThree.getPositionX(), BaseThree.getPositionY() );
No matter what I try, all my objects spawn at the same location.
Any idea what I am doing wrong?