Game Development Community

Cant get T2D tutorial graphics on Mac

by Kenneth Malone · in Torque Game Builder · 02/23/2006 (3:26 pm) · 9 replies

ISSUE:

I can't get the very first graphic up on the screen in T2D. I'd really like to see that little
spaceShip.

xxx
Suggestion to GG:In the Basic Tutorial that I received upon downloading T2D has an error.
Under LOADING IMAGES it says:
Important Step - Go back to the example folder. Now go to the spacescroller/client/images
folder, and ... (??? There are no example or client folders).

Suggestion to GG: At the end of the tutorial, put the complete code so newbies like me
have something to check it against. It would encourage me to buy more products.
xxx

Here is the code in game.cs

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


datablock fxImageMapDatablock2D(playershipImageMap)
{
mode = full;
textureName = "~/data/images/playerShip";
};

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

}

1) I've copied everything from the spacescroller/data/images to T2D/data/images.
2) I checked and the "playershipImageMap" is in my T2D/gameScript/game.cs file.
3) I get a thumbnail graphic when I click on the playerShip.png. So the file seems ok.

Q) Do I have something wrong with my code?
Q) Are my curly braces in the proper place? I've tried them in every position I can think of.
Q) Is T2D-OSX a seperate engine from the Torque Game Engine SDK?
Q) Do I have to do anything to the T2D-OSX executable?
When I was Getting Started in the 3D package I came across and executed this:
"Torque Game Engine Documentation Version 1.3x"/Setting up the Torque SDK on Mac OSX/ Appendix B. Setting up the Torque Game Engine/Compiling the Torque Game Engine SCK with XCode on OS X,
I was instructed to do the following:

Xcode Setup

Make sure that Xcode is installed and up to date. It can be installed from the Xcode Developer Tools CD that ships with Mac OS X 10.3. Once installed, it can be updated on Apple's developer site.

Installation instructions can be found in the document About Xcode Tools.pdf, also located on the Xcode Developer Tools CD.

Procedure B.1. Opening the Torque Project File in Xcode

1. Navigate to the directory where you downloaded Torque.
2. Inside this directory, you will see another directory called pb (an abbreviation for Project Builder, the predecessor
to Xcode). Open this directory.
3. Open the package called torque_pb_2_1.pbproj by double-clicking it.
4. Note
5. The first time you open torque_pb_2_1.pbproj, you may see a warning that it was created for an older version of
Xcode. Click OK.
It is advisable to specify the example directory as Torque's build location. The Torque executable must be in the same folder as the main.cs file and other script assets.

Procedure B.2. Setting Build Location

1. Open the Xcode->Preferences... window.
2. Select the Building icon from the sections at the top of the window.
3. Change the first radio button selection to Separate location for build products.
4. type in ../example. This will tell XCode to place build products in the example directory, relative to whatever base
directory you are working from.

Now when Torque builds, it will be placed immediately into the correct directory. This will let you run debug mode in Xcode, and prevent you from having to copy your executables from the default build location.

Q) Having done these things, does that effect T2D-OSX in any way?
Q) Are Torque SDK and T2D-OSX two separate engines?

#1
02/23/2006 (9:18 pm)
About the basic tutorial... Are you using the latest T2D? If so, the Basic Tutorial should not have the old fx... stuff in it.

fxImageMapDatablock2D -> t2dImageMapDatablock
fxStaticSprite2D -> t2dStaticSprite


About Xcode...

Sorry, but I'm not bothering with compiling T2D (or adding anything that would require a recompile) until it gets a little more developed. It's obvious that T2D is in a great state of flux and I have decided to work with what's there before I start mucking with the code.
#2
02/24/2006 (4:46 pm)
The Torque2D / aka Torque Game Builder tutorial does NOT, last I checked, require you to build the source code into an executable. But if you want to, you can build the engine from source, modify the source to your liking, all that good stuff... if you feel confident with c++.

Torque Game Builder is a separate engine from the Torque Game Engine.
They have much in common, though.

If you are looking for build instructions on the mac side, I first recommend you look at the latest versions of the engines. Torque Game Builder has a nifty beta release out, that we think is fairly stable. Torque Game Engine is currently at version 1.4.0, and we're looking to push 1.4.2 sometime soon. ( 1.4.1 was a special release for Ed Maurina's book: Game Programmer's Guide to Torque ).

/Paul
#3
02/26/2006 (2:43 pm)
I'm having the same problem with the tutorial and I'm using Windows. The image is not showing up when running T2D.

Here's my code:

//---------------------------------------------------------------------------------------------
// 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 custom code here
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 );
}

I copied over the images from the sidescroller directory and have made sure the playerShip.png file is in the directory.
#4
02/26/2006 (2:50 pm)
Looking in the console when I load T2D it says I have an error on line 29 which is:

$player = new t2dStaticSprite() { scenegraph = t2dScene; };

I've looked at this 3 times and it's exactly the same as the tutorial says it should be written. What needs to be changed?
#5
02/26/2006 (3:00 pm)
Got it working. It was a missing semicolon on the datablock function.
#6
03/03/2006 (12:46 pm)
Belated Thanks Anthony,
I've been away for a few days

I tried running your code with the semicolon at the end of the datablock function.
It doesn't seem to work on my iMac G5.

Does anyone know if that little guy (playerShip) is hiding behind the T2D graphic?
How do I push that graphic to the back?
#7
03/05/2006 (4:58 am)
I am on the Windows platform and stuck at this same spot.

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

datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip.png";
};


$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );
#8
03/05/2006 (6:05 am)
Try looking at the platformer tutorial in TDN, at "The Player" part.

tdn.garagegames.com/wiki/T2DScript/PlatformerPhysics

Perhaps not want you want, but it's a good reference to layers, the player datablock, and setting up the player.
It describes the layers in T2D or TGB, and how to set up a player. Though, there are some parts you don't want, as you are not making a platformer. ;)
#9
03/05/2006 (7:00 am)
Working on helping you troubleshoot this in a previous thread!