Sub-Classing
by Robert Fritzen · in Torque 3D Beginner · 08/22/2013 (12:53 pm) · 2 replies
This should (hopefully) be something easy.
Lets say I have somewhere around 230 gui bitmap buttons that need to have access to a unique onMouseOver, and I don't want to have to do:
or have to write functions for each (oh god no).
My initial though was the purpose of this thread. Is it possible to create a sub-class inside torquescript that parents another class?
IE: MySpecialGuiBitmapButtonCtrl -> GuiBitmapButtonCtrl
Lets say I have somewhere around 230 gui bitmap buttons that need to have access to a unique onMouseOver, and I don't want to have to do:
function GuiBitmapButtonCtrl::onMouseOver() {
if(%this.getName() $= "x" .. .. ..) {
//blah
}
}or have to write functions for each (oh god no).
My initial though was the purpose of this thread. Is it possible to create a sub-class inside torquescript that parents another class?
IE: MySpecialGuiBitmapButtonCtrl -> GuiBitmapButtonCtrl
About the author
Illinois Grad. Retired T3D Developer / Pack Dev.
#2
08/22/2013 (8:43 pm)
The 'class' and 'superclass' members let you do this. An object's name is also its lowest-level namespace. So you can do:new Thing(MyName) {};
function MyName::doThing() {}
MyName.doThing();Though obviously you can't give 230 objects the same name.
Torque Owner Scott Przybylski
HydroSim
I found this it might be useful www.garagegames.com/community/forums/viewthread/19224
Uh, and this one which is linked at the bottom of that one
www.garagegames.com/community/forums/viewthread/54797