Game Development Community

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.

About the author

Recent Threads

  • How to use vectors

  • #1
    12/29/2008 (5:06 am)
    You could use a ScriptObject like this:

    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");
    }
    #2
    12/30/2008 (5:09 am)
    OK Thanks. I didn't find the ScriptObject class