Game Development Community

Have a ImageMap question , please help me

by Chen Jay · in Torque Game Builder · 10/15/2007 (9:30 am) · 4 replies

Could you tell me a question
Why I use following way in TGB procedure, but can't demonstrate the picture while carrying out

$test = new t2dStaticSprite() {sceneGraph = t2dScene; };
$test.setImageMap( B5ImageMap ) ;
$test.setSize( " 8.261 11.929" );
$test.setPosition( " 25.870 22.305" );
$test.isSelectable = true;
$test.setVisible(true);
$test.LimitMode = " CLAMP" ;
$test.objectName = " B5" ;
$test.class = " B5" ;

There is a ImageMap that is named B5ImageMap in my Static Sprites
But type well above-mentioned establishment in the procedure
Pursue but not display, please help me to answer if not having wrong picture

thanks..

#1
10/15/2007 (9:39 am)
I don't see any errors in that code, but why not make things easier and put everything inside the brackets like this...

$test = new t2dStaticSprite()
{
sceneGraph = t2dScene; // make sure this is the correct name. or try scenewindow2d.getscenegraph();
imageMap = B5ImageMap;
Size = "8261 11.929";
Position = "...";
...
}

Also make sure the code is actually getting executed.
#2
10/16/2007 (7:08 am)
Sorry...
Also can't display.
I don't see any errors in that code too.
#3
10/23/2007 (10:40 pm)
Make sure you're using the correct scenegraph name. What I do is have my player object's onLevelLoad command do something like this:

function playerClass::onLevelLoaded(%this, %scenegraph)
{
$player = %this;
...
...
...
}

from then on, whenever you need to access the current scenegraph you can use:

$test = new t2dStaticSprite()
{
scenegraph = $player.scenegraph;
...
...
}
#4
10/24/2007 (12:30 pm)
You need to change this:

test = new t2dStaticSprite() {sceneGraph = t2dScene; };

=> test = new t2dStaticSprite() {scenegraph = SceneWindow2D.getScenegraph(); }; or whatever the name of your actual scene window is. The default is SceneWindow2d.