Game Development Community

Pretty Simple Namespace Question

by Michigan State University (#0021 · in Torque Game Engine · 05/31/2006 (11:12 am) · 2 replies

It seems, by looking throughthe Game Programmer's Guide, that it should be pretty simple to add namespaces under the engine defiend ones. However, I'm not able to get it to work correctly for some reason.

The examples provided are talking about adding namespaces to the datablocks, but I would like to, if possible, add them to the individual objects. Is the syntax different? Is it possible? How would I go about doing it?

P.S. Completely unrelated, but a quick aside nonetheless, when a GUI element is pushed onto the canvas using pushDialog(), does it trigger an event like ::onAdd() or ::onWake()?

#1
05/31/2006 (12:01 pm)
I don't think that's possible. someone correct me if I'm wrong.

dont consider game objects as programming objects. datablocks are the objects which most closely resemble classes with methods and inheritance. regular game objects can inherit fields, but not functionality. ALL object methods must be added either under a datablock namespace, or a class of the object hierarchy. if you require functionality unique to a particular object, your only choice is to use a datablock function. regular game objects should be considered as object instances rather than object definitions.
#2
05/31/2006 (12:50 pm)
Small caveat to Sean's post: if you don't want to change the source code.

You can certainly implement a new class (or change the underlying classes, although be careful) to have unique namespaces per object's name, but it will require (minimal) c++ changes and a recompile. In fact, this is exactly what the gui objects do--they change the ::onAdd() to link to not only the c++ classes' inheritence based namespaces, but the object's name as a unique namespace as well.