Game Development Community

A question about script class ?

by KevinYuen · in Torque 2D Beginner · 08/01/2013 (1:41 am) · 2 replies

function BaseClass::FuncA( %this )
{
	echo( "BaseClass::FuncA" );
}

function InheritClass::FuncB( %this )
{
	echo( "InheritClass::FuncB" );
}

%classA = new SimSet( BaseClass );
%classB = new SimSet( InheritClass : BaseClass );
%classB.FuncB();
%classB.FuncA();

error: Unknown command FuncA.
  Object InheritClass(1266) InheritClass -> SimSet -> SimObject

I want to make a derived class,
like C++:
class CA : public CB
Is there any way to solve it?

#1
08/01/2013 (1:49 am)
if (!isObject(GuiTransparentProfile)) new GuiControlProfile (GuiTransparentProfile : GuiDefaultProfile)
{
    opaque = false;
    border = false;
};

Above code, the format: new CONOBJECT( OBJECTA : OBJECTB ), Who can explain to me, thank you :).
#2
08/01/2013 (4:26 am)
ObjectA : ObjectB means ObjectA will be a copy of ObjectB, rather than a namespace inheritor. So ObjectA will have all the same data fields, but it won't be in the ObjectB namespace.

To get a limited form of inheritance you need to use the class and superclass members. But those are the only two levels of inheritance you have, plus the object name. So it looks like this:

Object name -> Script class -> Script superclass -> Engine class -> Other classes above that

You can choose the name, script class and script superclass, but you can't choose the engine class or any of the inheritance above that level.