How to create some classes with TGB
by Antoine AGTHE · in Game Design and Creative Issues · 12/29/2008 (12:46 am) · 2 replies
Hi,
My problem is pretty simple to understand, but I can't find any solution.
I just want to create a class that doesn't link with a SceneObject. It will be a class that deals with alphanumeric values. No graphic ressources.
I started creating a ".cs" file that described methods of my class, like that:
#########
# MyClass.cs
#########
MyClass::myFirstMethod( %this ) {
...
}
MyClass::mySecondMethod( %this ) {
...
}
...and then I thought I could do:
########
# somefile.cs
########
exec( "./MyClass.cs" );
%myObject = new MyClass();
%myObject.myFirstMethod();
%myObject.mySecondMethod();
... but it doesn't work.
My problem is pretty simple to understand, but I can't find any solution.
I just want to create a class that doesn't link with a SceneObject. It will be a class that deals with alphanumeric values. No graphic ressources.
I started creating a ".cs" file that described methods of my class, like that:
#########
# MyClass.cs
#########
MyClass::myFirstMethod( %this ) {
...
}
MyClass::mySecondMethod( %this ) {
...
}
...and then I thought I could do:
########
# somefile.cs
########
exec( "./MyClass.cs" );
%myObject = new MyClass();
%myObject.myFirstMethod();
%myObject.mySecondMethod();
... but it doesn't work.
Torque Owner Shaderman
function TestMyClass() { %myObject = new ScriptObject() { class = MyClass; }; %myObject.myFirstMethod(); %myObject.mySecondMethod(); } function MyClass::myFirstMethod( %this ) { echo("MyClass::myFirstMethod was called"); } function MyClass::mySecondMethod( %this ) { echo("MyClass::mySecondMethod was called"); }