Torque2D/pong Tutorial TGB Setup

From TDN

This page is a Work In Progress.

Contents

Setting Up TGB


Setting up the Folders

The new folder layout is wonderful. It makes for a more organized project. I take this one step further in the image folder by seperating the gui images from the game images. This version of the game only requires three images for the game and five images for the gui. Eight images does not really need alot of organization. However, for larger projects, this additional organization may be necesary.
Just add two new folders in the "pong/data/images" folder. Name one "gui" and the other "game".
Move all the gui images to the gui folder and the game images to the game folder. By the way, a complete code listing is available on the overview page.

Restructuring some files

Let's start out by adding a file called "exec.cs" in the gameScripts directory. We'll use this file to execute all of our script files and to have a place to initialize our global variables. To initialze this file we need to place this line in "pong/main.cs" file in the onStart() function. Place it after the other exec entries.

// Execute our scripts
exec("./gameScripts/exec.cs");

We'll also want to comment out the call to toggleLevelEditor() in the same function. It's a little overkill for this tutorial.

//toggleLevelEditor();

In the levelEditors place, we'll want to add

setupT2DScene();

OK now's let's open up "pong/gameScripts/initializeT2D.cs". Remove the following code from the initializeGame() function, and place it in the newly formed "pong/gameScripts/exec.cs" This step is not required. But this will help keep everything consistant, All the scripts can be loaded up from the same place.

// Load up Datablocks.
exec("~/data/content/datablocks.cs");
   
// Load up GUIs.
exec("~/gui/mainScreen.gui");

Section 2


Section 2 SubHeading 1
Section 2 Subheading 1 Copy

Section 2 Subheading 2
Section 2 Subheading 2 Copy




Overview | Next - The Game Arena