Torque Game EngineTorque Game Engine Documentation
Version 1.3.x

Putting It All Together

Now that you have created and saved your new GUI control as well as your new button control, we will tie them together and create a clickable button that launches your Hello World window!

In order to do so, we have to tell the engine that we're using a new GUI element. For this to happen, we'll have to add a simple line to some script code.

To add the script code, first browse to the location where the Torque SDK is installed. Once there, browse to "example\starter.fps\client". For example, if your copy of the Torque SDK is installed in C:\, browse to C:\torque\example\starter.fps\client. See Figure 36 for an example.


             Figure 36

Figure 36

Now, find and open the file "init.cs" in your favorite text editing program. The screenshots below use jEdit. You can open the file by right-clicking it, choosing the Open With... option from the pop-up menu, and then selecting your text-editing program.

Once you have the file open, look for the block of code that starts with the comment:

          // Load up the shell GUIs.
        

This is shown in Figure 37.


             Figure 37

Figure 37

Just after the last line of that block of script, enter the following line of code

          exec("./ui/HelloWorld.gui");
        

It is extremely important that you enter the line above exactly as you see it. Otherwise, this script file will fail to compile. See Figure 38 for details.


             Figure 38

Figure 38

Adding the above line of code tells Torque that we are using a new GUI element, and to load it up.

Once you are confident that you entered the code correctly, you may now save the edited "init.cs" file and close out of your text editor.

Now, load up the Torque Demo Application again. When the main menu loads, click the My First Button button that you created. When you do so, your Hello World dialog should appear!

If the dialog doesn't appear, carefully double-check that you correctly followed all the steps in this chapter, and entered code exactly as it was presented. Everything will work if you have done so.

Congratulations on creating your first GUI controls!


             Figure 39

Figure 39