Game Development Community

CLOSE

by Tim Tebow · in Torque Game Builder · 10/01/2008 (5:36 pm) · 15 replies

---

#1
10/01/2008 (5:48 pm)
Make sure you are setting the sceneGraph, position, and size when you spawn it, also an image/frame.
#2
10/01/2008 (5:49 pm)
-
#3
10/01/2008 (6:02 pm)
Here is what I was kinda using

%this.turret = new t2dStaticSprite()
{
sceneGraph = %this.scenegraph; // make sure to set the scenegraph
ImageMap = "tankTurretImageMap"; // set the image to use
config = "PhysTankTurretDatablock"; // set the config datablock
};

which was pulled from here

http://tdn.garagegames.com/wiki/TGB/MiniTutorials/SimpleTankPhysics
#4
10/02/2008 (8:39 am)
I also tried this

%test = new t2dStaticSprite() { scenegraph = %this.sceneGraph; };
%test.setPosition("0 0");
%test.setSize("10 10");
%test.setImageMap(particles1ImageMap);
%test.setLayer(2);
%test.setEnabled(true);


That code wont even run for some reason. Any ideas on what im doing wrong?
#5
10/02/2008 (12:01 pm)
It won't run? I don't see any syntax errors. %this.sceneGraph looks a bit dodgy, but could make sense i guess depending on what function/method this is inside. Usually I do something like this in startGame.

// loadLevel
// etc..
$sceneGraph = sceneWindow2D.getSceneGraph();

Then i always use $sceneGraph when allocating objects.
#6
10/02/2008 (12:34 pm)
Ill try that, im looking at someones elses post also right now about the same issue, seems about 4 or 5 of us had the same issue around the same time which is odd.
#7
10/02/2008 (1:28 pm)
Does the console spit out anything relevant? (the console.log file in your game project folder)
#8
10/02/2008 (9:55 pm)
After reading your post on the thread I started, I looked up your thread to see what all was going on. I am still not getting my spawn to display, and I'm not real sure how to look at the sceneobjects to see if it is there.

If I use one of the spawn generators, objects spawn with an error, but they behave the way I want them too. Again though, I'm with Austin here in that I don't want to clone an object. Here is the spawn code I am using.

I changed the sceneGraph from what I had to the global like James suggested above. As anyone gotten anywhere with this. I want to spawn a random mob at some point in my game, but it isn't working.

I based my code off of my lightning bolt code that is a projectile the player fires. That works fine and shows up.

I receive no errors in my console log, it just displays the echo messages.

function SpawnMobs()
{
//add random creature mob at later date.

%spawnMob = new t2dStaticSprite()
{
scenegraph = $sceneGraph;
};

spawnPoint1(%spawnMob);
}


//spawnPoint1

function spawnPoint1(%this)
{
if (!isObject(%this))
{
echo("not an object");
return;
}

else
{
echo("establishing spawn data");

%this.setImageMap(devilImageMap);
%this.setSize(56.391,78.185);
%this.setPositionX(-159.449);
%this.setPositionY(-263.608);
%this.setLinearVelocityX(1000);
%this.setLinearVelocityY(1000);
%this.setLayer(1);
}

}
#9
10/03/2008 (5:21 am)
Here is what my code ended up being to work.

game/gameScripts/game.cs

added
$sceneGraph = sceneWindow2D.getSceneGraph();
at the bottom of startGame

Then in my function page I created I have

%test = new t2dStaticSprite() { 
         scenegraph = $sceneGraph; 
         class = SunClass; 
         Layer=1; 
         imageMap = particles6ImageMap;
         size = "10 10";
         position = "1 1";
      };


after I did that everything worked. It seems something was messed up when I tried to use t2dSceneGraph and %this.scenegraph to try to display anything.
#10
10/03/2008 (11:11 am)
You are a life saver. I am developing this game for a school project and was at a huge stuck point. Thanks a ton. This works for me as well.
#11
10/03/2008 (11:28 am)
Awesome '-)
#12
10/21/2008 (9:11 am)
It has happen to me several times that

scenegraph = %this.sceneGraph;
doesn't works

scenegraph = %this;
but this does.
#13
11/09/2008 (5:59 am)
Thanks, I have been struggling with this aswell. I have one question though. How do you need to tweak this code if you want to create a text object?

I guess you have to change "t2dStaticSprite" to something else (something like "t2dTextObject" for example, but I dont know the correct scripting here).

I guess the following lines also should look different. I mean you probably dont need to set an ImageMap and such.

Could somebody please write down an example of the text object creation, in the same way as the static sprite example is given. I would really appreciate it.

Thanks in advance!
#14
11/09/2008 (6:22 am)
Sobo try this

%test = new t2dTextObject() {
      scenegraph = %this.sceneGraph;
      size = "30.000 4.000";
      text = "Sample Textobject";
      font = "Arial";
      wordWrap = "0";
      hideOverflow = "0";
      textAlign = "Left";
      lineHeight = "4";
      aspectRatio = "1.00066";
      lineSpacing = "0";
      characterSpacing = "0";
      autoSize = "1";
      fontSizes = "102";
      textColor = "1 1 1 1";
   };
#15
11/09/2008 (6:53 am)
Thank you very much Shaderman! It worked perfectly!
.