Game Development Community

Switch GUI objects

by Chris Robertson · in Torque Game Engine · 01/25/2004 (5:37 pm) · 1 replies

I have two guis that contain the same controls, but are laid out differently. They are used as the HUD for 1st and 3rd person views respectively. I also have a number of support functions that act on the gui to turn on/off various indicators, output text etc.

eg.

myHud::showText(%str)
{
textCtrl.text = %str;
}

In this case, the control called 'textCtrl' exists in both guis, but I would like to update whichever one is active.

I do not want to have to duplicate the support functions for each gui, and ideally would like to be able to 'switch' which object they refer to on the fly.

Essentially, I want to be able to redefine a gui object, so that I keep all the same names and functionality.

Is this possible? Any alternatives?

#1
01/25/2004 (9:16 pm)
Why not have it reference the current gui in a global and then get to stuff through that?

$HudGUI.textCtrl.text = %str;