Game Development Community

T2DBasicTutorial1 No ImageMaps are seen.

by Peter Dannenberg · in Torque Game Builder · 03/04/2006 (3:56 pm) · 3 replies

Hi,
I'm currently working my way through the getting started tutorial and I'm using T2D version beta 1.1:
http://tdn.garagegames.com/wiki/Torque_2D/Getting_Started/T2DBasicTutorial1

I noticed when setting up the playership the tutorial uses these method calls:
datablock fxImageMapDatablock2D(playershipImageMap)
$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };

However the T2D console reports
"Unable to instantiate non-conobject class fxImageMapDatablock2D"
"Unable to instantiate non-conobject class fxStaticSprite2D"

However just a little way down the tutorial to make the enemy ship those previous method calls are replaced with 2dImageMapDatablock and t2dImageMapDatablock.

Anyway on to my real problem. Below you'll find the code for my game.cs located int the T2D/gameScripts/ directory.
My problem is when I run the T2D game I only see the black T2D background and I don't see either sprite for the player or the enemy. I'm thinking their position might be out of view. The console window doesn't report any errors. So I'm looking to see if anyone else had experienced this problem or has any recommendations as to why I can't see the sprites on such a simple tutorial.
thanks,
Peter

//---------------------------------------------------------------------------------------------
// 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");

// set up the enemy
datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

%enemy = new t2dStaticSprite() { scenegraph = t2dSceneGraph; };
%enemy.setSize( "-35 0" );
%enemy.setPosition("14 7");
%enemy.setImageMap( playershipImageMap );

// set up the enemy
datablock t2dImageMapDatablock(enemyship1ImageMap)
{
imageMode = full;
imageName = "~/data/images/enemyship1";
};

%enemy = new t2dStaticSprite() { scenegraph = t2dSceneGraph; };
%enemy.setSize( "14 7" );
%enemy.setPosition("40 0");
%enemy.setImageMap( enemyship1ImageMap );
}

#1
03/04/2006 (4:07 pm)
Looks like you've got your setSize and setPosition switched around... and you're creating two enemy objects and no player object
#2
03/04/2006 (4:13 pm)
Thanks Wes,
Yes I had those switched around, thanks for pointing that out. I also fixed the duplicate enemy object. the one thing that the console outputs that concerns me is:
t2dImageMapDatablock::CalculateFullImageMap() - ImageMap (playershipImageMap) disabled 'filter-padding as it was unnecessary!'

t2dImageMapDatablock::CalculateFullImageMap() - ImageMap (enemyshipImageMap) disabled 'filter-padding as it was unnecessary!'

Although so far both sprites are not showing up against the background. My next step is to go through the details of each method to see if there's something I forgot to initialize. Any suggestions or recommendations from anyone is greately appreciated.
Peter

Here's a update of my current code base:

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");

// set up the enemy
datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

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

// set up the enemy
datablock t2dImageMapDatablock(enemyship1ImageMap)
{
imageMode = full;
imageName = "~/data/images/enemyship1";
};

%enemy = new t2dStaticSprite() { scenegraph = t2dSceneGraph; };
%enemy.setSize( "14 7" );
%enemy.setPosition("40 0");
%enemy.setImageMap( enemyship1ImageMap );
}
#3
03/04/2006 (5:49 pm)
I found the problem and have updated the tutorial.
The issue was the scenegraph was defined as t2dScene and not t2dSceneGraph as shown below
we defined our t3dSceneGraph as t2dscene and not t2dsceneGraph so the problem was a simple typo.
// Create our scenegraph
new t2dSceneGraph(t2dScene);

//original tutorial code
%player = new t2dStaticSprite() { scenegraph = t2dSceneGraph; };
//updated tutorial code
%player = new t2dStaticSprite() { scenegraph = t2dScene; };

Thanks for your help!