Chapter 10: Creating GUI Elements


Overview

As you've seen by now, there is more to a 3D game than just the imaginary world into which the player plunks his avatar. There is the real need to provide the player with some method to make selections and otherwise control the game activities. Generally, we provide a Graphical User Interface (GUI) to the player to interact with the program. The menu we employed at the start-up of the program, where the player clicks on buttons to launch the game, change the setup, or quit; the dialog box that shows the client's loading progress; the dialog box that asks if the player really wants to quit— these screens are all examples of GUIs.

If you take a look at Figure 10.1, you can see a sample of the variety of elements found within these interface screens.

click to expand
Figure 10.1: Common graphical user interface elements.

Some of the elements are things we can interact with:

  • push buttons

  • radio buttons

  • edit boxes

  • check boxes

  • menus

  • sliders

Some of the elements are things we can just look at:

  • frames

  • labels

  • backgrounds

Also, during the course of discussions about graphical user interfaces, you may find the terms GUI, window, interface, and screen used interchangeably. I'll stick to the words interface and screen as much as possible, although contextually it might make more sense to use GUI or window from time to time. GUI is best used to describe the entire game interface with the player as a whole. Window is a term that most people tend to associate with the operating system of their computer.

The names of GUI items that are available by default with Torque don't differentiate between whether they are interactive and noninteractive GUI elements.

If you are familiar with X-Windows or Motif, you will probably have encountered the term widgets. If so, your definition of widgets may be a fair bit broader than the one I am about to use here. In our situation, widgets are simply visual portions of a displayed GUI control. They convey information or provide an aesthetic appearance and offer access to defined subcontrol elements.

For example, Figure 10.2 portrays a scroll bar. Within the scroll bar are the thumb, arrow, and bar widgets. These aren't controls in their own right but rather are necessary specialized components of the control to which they belong.

click to expand
Figure 10.2: Scroll bar widgets.

It is possible for a control to use another control as a widget. In fact, every control in a screen can be considered a widget within the control that defines the screen. This will become clearer later on. I will only use the term widget to refer to a specialized component of a control that is not itself a control.

Worth noting is the fact that you can create your own GUI elements using Torque Script if the ones that are available by default don't suit your needs.




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