Game Development Community

First T2D Tutorial - Stuck

by David Taylor · in Torque Game Engine · 03/19/2006 (9:53 pm) · 3 replies

As embarrassing as it is to admit it, the first piece of code in the BasicTutorial.pdf has me stumped. As far as I can tell, my game.cs scripting should read like this:

//---------------------------------------------------------------------------------------------
// Torque 2D.
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------
// setupT2DScene
// This function is the starting point for all game specific code.
//---------------------------------------------------------------------------------------------
function setupT2DScene()
{
// Create our scenegraph
new t2dSceneGraph(t2dScene);

// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dScene );

// Set the current camera position
sceneWindow2D.setCurrentCameraPosition("0 0 100 75");

// add an image to the screen
datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";

$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize("14 7");
$player.setImageMap(playershipImageMap);
};

}

That is supposed to draw an image, (playerShip.png), to the screen, but it doesn't. As the documentation doesn't show the complete code required after each step, I may well have put portions in the wrong area, although the following has nothing drawing either:

//---------------------------------------------------------------------------------------------
// Torque 2D.
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------
// setupT2DScene
// This function is the starting point for all game specific code.
//---------------------------------------------------------------------------------------------
function setupT2DScene()
{
// Create our scenegraph
new t2dSceneGraph(t2dScene);

// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dScene );

// Set the current camera position
sceneWindow2D.setCurrentCameraPosition("0 0 100 75");

// add an image to the screen
datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize("14 7");
$player.setImageMap(playershipImageMap);

}

Can anyone explain what I've done wrong here?

#1
03/20/2006 (11:21 am)
I highly suggest that you use the "Edit Subscriptions" link to subscribe to the private Torque Game Builder forums--you will get much more appropriate help there for TGB questions!
#2
03/20/2006 (4:18 pm)
Thanks, Stephen. I couldn't actually find that forum - could you link me?