Creating an Interface


In this section, you will see how easy it is to create and employ an interface using the Torque GUI Editor.

You should note that the Torque GUI Editor assumes your screen resolution is set to a minimum resolution of 800 600. You may find it more useful to use a higher resolution, to allow the different views more room to display their data.

  1. Using Windows Explorer, browse into the C:\3DGPAi1 folder and then double-click on the Run fps Demo shortcut.

  2. When the GarageGames/Torque menu screen appears, press the F10 key.

    The editor controls will appear on the bottom and right side of the screen and enable you to immediately start editing the screen you were previously viewing.

  3. Click the New button and enter a name for the new interface—do not use spaces in the name. Use "MyFirstInterface" for the name.

  4. Leave the class as GuiControl, and then press the Create button. You will now have a nice new interface to work with.

  5. In the Tree view, select the control named "MyFirstInterface". Its properties should appear in the Inspector view.

  6. In the Inspector view, click the Expand button.

  7. Locate the profile property and click the button next to it to get the pop-up menu.

  8. Scroll through the menu until you locate the GuiContentProfile and select that.

  9. Click Apply.

    Now you have a Content Control to which you can add other controls.

  10. Click the New Control button and choose GuiButtonCtrl from the pop-up menu.

  11. Select the button using one of the two techniques you've learned (via the Content Editor or via the Control Tree).

  12. Look in the Control Inspector view and locate the text property for this new control. Put some text in it.

  13. Enter "quit();" in the command property.

  14. Click Apply.

  15. Click the Save button.

  16. The Save feature will automatically use the top-level control in your interface for the file name, so leave that as is.

  17. At the top of the Save dialog box is a button that you can use to select which folder in which to save the file. Choose the fps folder.

  18. Click Save.

There, you've created an interface using the Torque GUI Editor!

Now let's break it! NoI mean, let's test it!

  1. Open the console using the Tilde key ("~").

  2. Type in the following, pressing the Enter key when you're done:

        exec("fps/MyFirstInterface.gui"); 
  3. Now type in the following, again pressing the Enter key when you're done:

        canvas.setContent("MyFirstInterface"); 

Your interface should pop up on the screen. Just go ahead—press that button! Now you see that the whole program quits, because that's what you programmed it to do.

Of course, this is a simple interface. They can get as complex as you need. You can see that there is a lot of power available in Torque to address your interface needs. And if Torque doesn't have it, you can create it yourself!




3D Game Programming All in One
3D Game Programming All in One (Course Technology PTR Game Development Series)
ISBN: 159200136X
EAN: 2147483647
Year: 2006
Pages: 197

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net