Game Development Community

Static variables in GUI Editor

by Mike Damert · in Torque Game Engine · 10/08/2004 (5:53 pm) · 2 replies

The GUI Editor is reacting very strangely to my attempts to use static member variables in GUI components, and I'm not sure whether this strange behavior is a result of my ineptness or a bug in Torque (I'm using version 1.3).

I go into guiChunkedBitmapCtrl.cc and add a static variable:

static S32 mStaticInt;

I initialize this later in the file with the line:

S32 GuiChunkedBitmapCtrl::mStaticInt = -1;

And I add a line to the initPersistFields() function:

addField("staticint1", TypeS32, Offset(mStaticInt, GuiChunkedBitmapCtrl));

Now I fire up Torque and enter the GUI Editor, and here the problem arises. When I try to look at the MainMenuGui, the stated value of "staticint1" is a random number. This behavior is even stranger, given that each time I re-click on MainMenuGui, the value for "staticint1" seems to have changed. Has anyone else encountered this behavior?

#1
10/08/2004 (7:06 pm)
Have you tried...


mStaticInt = -1;
#2
10/08/2004 (8:54 pm)
I looked at the offset macro, but I couldn't quite figure out what it was doing...thanks for the explanation!