Game Development Community

New Torque2D Users/Beginning Tutorial Problems and Solutions

by Matt Kelly · in Torque Game Builder · 02/10/2006 (6:07 pm) · 16 replies

Being a new user of Torque2D, I ran into a few problems early with the new Beta 1.1. First of all, I had no idea how to "compile" the game. With Blitz, it was a simple click of a button. However, in the beginner's tutorial there is no documentation of how to "compile/debug" a Torque2D game. Thanks to the IRC channel (highly recommended for help- they have been GREAT thus far (irc.maxgaming.net #garagegames and #torque2D)), I was enlightened on the issue. I have noted that the new checker's multiplayer tutorial sheds light onto the issue, but I think it should be added into the beginner's tutorial.

I have stumbled upon a couple of mistakes in the beginner's tutorial. However, I would like to say that launching a game can be tricky at first. Actually, it's based on a mistake made by me. When I was editing the "main.cs" in the root "\games" directory, I changed "$runWithEditors = false;" to true. Boy was that a mistake. It took me an hour or two to figure out I needed to add "setupT2DScene();" into my game's "main.cs" file. The problem was that when the editors variable was set to false, it didn't show any sprites (in reality it didn't launch my game at all). When I put the editors back on, and ran the game from the menu, the sprites showed up. It befuddled me. Hopefully newbies can be directed to this blog post to clear up similar problems in the future.

Problems with the Basic (Beginner's) Tutorial:
The reason the basic tutorial contains errors is because the functions used in it have been deprecated with the new Beta 1.1 version.

First Problem: Deprecated setGroup function.
Solution: Change function to "setGraphGroup".
List:
$player.setGraphGroup( 1 );
%enemy.setGraphGroup( 2 );
%enemyFire.setGraphGroup( 2 );
%projectile.setGraphGroup( 1 );

Second Problem: The T2DTileMap object isn't visible.
Could not locate texture: tools/tileEditor/gui/images/collisionButton
t2dTileLayer::setStaticTile() - t2dImageMapDatablock Datablock is invalid! (bgBlankSkyImageMap)
Solution:
None yet. The game still runs, but the tilemap doesn't scroll. Any suggestions? Post a reply.

Thanks!
Matt

original blog post about the issue

#1
02/10/2006 (11:32 pm)
Ya my tile map stopped scrolling as well, this was code used from the platformer tutorial.
#2
02/11/2006 (2:01 am)
Matt,

Not everything is sync'd up at the moment, it all takes time and lots of effort. T2D is progressing so fast that the updates both on TDN and the SDK doco lag behind a little. Every effort is made to keep the internal docs updated but occasionally, we miss a function or two. For how many functions there are, we're doing pretty well I think. :)

This is not to say that it isn't a problem, especially for starters to T2D, but it is the reason and I do appreciate you highlighting the perspective of a beginner as it's a great test of the whole T2D package.

You can be sure that we're addressing the ease of use and documentation for the SDK, especially for beginners.

Sorry for any teething problems you've had so far though.

- Melv.
#3
02/11/2006 (7:44 am)
Also, just to add...

- "setGraphGroup()" and "getGraphGroup()" has been added to the internal doco.

- The t2dTileMap doesn't render because it's just the parent object; the tile-layers are the things that render.

- "tools/tileEditor/gui/images/collisionButton" is just a warning, not an error and it's cause by an odd method used in one of the bitmap-buttons. Renaming the "collisionButton_n.png" image to "collisionButton.png" removes the warning. Again, this is only a warning and doesn't affect functionality. We've corrected this in the internal build.

- "Datablock is invalid!", there are many things this could be (presumably there's an error preceeding it) but the most obvious reason is that there's a erroneous description in the tutorial docs where it states to copy the images from. This has also been corrected in the internal build.

Hope this helps,

- Melv.
#4
02/11/2006 (9:29 am)
OK... I just went through the Tutorial PDF.... and other then the setGraphGroup... everything else seemed to be OK.. I think there were a couple typo's.... but nothing wrong with the tileScroller. Other then I didn't see where it said to add the CreateTileMap(); call after the SetupImages(): call in the setupT2DScene function.

OK upon further review... it does tell you to put the call in the SetupT2DScene() function.
#5
02/11/2006 (9:57 am)
If you could pass those typos along Harold, I'll get 'em fixed-up.

- Melv.
#6
02/11/2006 (10:07 am)
Whenever you refer to getting files from the SpaceScroller demo you use the old path structure, not the new one.

/SpaceScroller/client/
#7
02/11/2006 (11:56 am)
Melv: To be honest, I didn't mean to sound like I was complaining in my blog post. I understand how hectic it is for all of you at GG currently, so I took it upon myself to help out new users by telling them how to properly get through the basic tutorial. Actually, I'm happy there are "official" tutorials at all- they're all very well done! Keep up the great work.

Matt
#8
02/11/2006 (5:08 pm)
@Harold: Okay, gotcha'. I thought you mean spelling issues etc. :)

@Matt: No problem, I didn't think you were complaining and if you were, it's entirely your right but you are correct, it is hectic trying to get everything together, especially with so many people working on T2D now. Either way, it's a sign that T2D is moving along at a pace so it's all good. :)

- Melv.
#9
02/11/2006 (10:50 pm)
Melv: Is there any way you can post a work-around to get the scrolling tilemap to work?

Thanks,
matt
#10
02/12/2006 (12:07 am)
Matt... it does work

If you'll read my post... I downloaded Beta 1.1, and went through the tutorial... I copy and pasted the code as it appeared in the PDF.... at the end the only error I had was the SetGroup change.


Look at your datablock for the bgBlankSkyImageMap
#11
02/26/2006 (1:27 am)
I'm using the tutorial that came with my T2D_SDK-1.1

Why are the projectiles done with % but the player and enemy ship done $?
Because of this I think there are a few references to the enemy ship that don't seem to work.

I've noticed code on pages 8, 18 and 21 have this.

I've also noticed that in the collision section it talks about "setCollisionPolyScale()" but those are only used on the projectiles. "setCollisionPolyCustom" is used on the ships so a bit of info about that would be nice even thought it's obvious what it does.

I haven't started on the tilemap section yet so I will keep you posted if I find anything there.

Thanks for this great writeup. It's written to exactly the kind of level I need. Eventually some kind of cross reference where you could click functions etc to get more information about them would be great. Just an idea. :)

edit - fixed some terminolgoy I got wrong about $ and %
- there are also a few cases of the % and $ thing in the tilemap sction
#12
02/26/2006 (2:41 pm)
Where can I get the updated Beginning Tutorial? I'm currently going through the Revision 1.6 that came with the download and it's not working for me. I'm wondering if I have an old version of the tutorial.
#13
03/05/2006 (6:12 am)
Is there an updated Basic Tutorial.pdf -- I am about ten hours into getting one simple sprite on the screen as described by page withthe first 'Run Game', this has become a frustrating exercise.
#14
03/05/2006 (6:59 am)
I mentioned the state of the tutorials vs the codebase in a previous thread, but since you appear to be online here right now, let's try to work out your specific issue.

First, I want to do some debug steps to see if what I think may be happening is happening...

If you are following the tutorial exactly, you are working with the game.cs file. I'd like you to be able to confirm that this file is in fact being loaded, so please add the following to the top of that file:

error("Loading in gameScripts/game.cs!!");

Then shutdown T2D, run the cleandso.bat file in your /games directory (this deletes all pre-compiled versions of your script files, which should guarantee that you are loading in fresh copies of all of the script files). Note also that I intentionally selected "error" as the command, even though this is simply a debug message: I did that so that the line will show up in red in the console, and be easily seen.

My first guess is that file isn't being loaded at all, so if you do the above, and do not see the message, then this is your problem. Go to your /T2D/main.cs and confirm that you see:

exec("./gameScripts/game.cs");

Also, scan back over your console.log and make sure that you do not see any other red messages. If you do see them, please post them here. Also, while scanning your console output, please report if you have any Script Error notes in any lines.

If the above works (you see the line we added), then the next step is to get a way to access your ship object directly:

After your game has run, open the console, and type in:

$player.dump();

The output should be pretty long, please cut/paste it here (note that your console output is saved to a file in your /game dir called console.log, can be easier to edit that in some cases) and we can proceed with debugging.
#15
03/05/2006 (7:41 am)
Just to add on here, as all your code seems to be in setupT2Dscene(), are you actually calling the function?
setupT2DScene();

If not, try putting it in the onStart() function.
For example:

function onStart()
   {
      Parent::onStart();
      echo("\n--------- Initializing MOD: T2D ---------");
      
      // Load Client Scripts.
      exec("~/data/content/sampleDatablocks.cs");
      exec("./gameScripts/initializeT2D.cs");
      exec("./gameScripts/game.cs");

            
      initializeGame();
      //toggleLevelEditor();
      setupT2DScene();
      
      Canvas.setCursor(DefaultCursor);
   }

I got mine to work using the following code (Just copying + pasting the platform TDN code. See TDN platform tutorial.):
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");
   
new t2dImageMapDatablock(playerImageMap)
{
   imageMode = "full";
   imageName = "~/data/images/playerShip";
};

   
   $player = new t2dStaticSprite()
   {
      scenegraph = t2dscene;
   };
   $player.setImageMap(playerImageMap);
   $player.setPosition("-35 0");


}
#16
03/05/2006 (8:34 am)
For those that may be interested the basic tutorial on TDN is now up to date and working with the latest Beta1_1 version of T2D.

tdn.garagegames.com/wiki/Torque_2D/Getting_Started/T2DBasicTutorial1