Can't mount objects with a class?
by Joe Rossi · in Torque Game Builder · 05/18/2008 (7:49 pm) · 4 replies
I'm trying to mount a text object I made set with a class I wrote allowing it to accept input events like mouseover and clicks. But when I try to mount my object to a staticSprite, I get an error:
"Namespace::unlinkClass - cannot unlink namespace parent linkage for ObjectListText for t2dStaticSprite.
Error: cannot change namespace parent linkage of ObjectListText from t2dStaticSprite to t2dTextObject."
What am I doing wrong? All I'm doing is mounting a textObject to a sprite.. nothing fancy. It just happens to have a class so it can accept input.
Here's a small example of what I'm doing:
Any tips or workarounds would be much appreciated.
"Namespace::unlinkClass - cannot unlink namespace parent linkage for ObjectListText for t2dStaticSprite.
Error: cannot change namespace parent linkage of ObjectListText from t2dStaticSprite to t2dTextObject."
What am I doing wrong? All I'm doing is mounting a textObject to a sprite.. nothing fancy. It just happens to have a class so it can accept input.
Here's a small example of what I'm doing:
%t = new t2dTextObject() {
class = "ObjectListText"; // my class
scenegraph = %this.owner.scenegraph ;
layer = %this.owner.layer;
canSaveDynamicFields = "1";
useMouseEvents = "1";
BlendingEnabled = "1";
};
%t.mountToLinkpoint( %this.option[%i] , 1, 0, 0, 1, 1, 1 );Any tips or workarounds would be much appreciated.
#2
05/18/2008 (9:46 pm)
Thanks Phillip you were right. I have too much code lol. I still wonder why TGB won't allow different types of objects share the same class... I find myself having to create redundant code due to this "feature" :P
#3
I believe that this "feature" is a consequence of hierarchical nature of class namespaces. In a hierarchy, each class can only have one parent. In this case, t2dStaticSprite and t2dTextObject are children classes of t2dsceneobject. By assigning a script class to both, you're essentially trying making the script class a child of both, violating the definition of a hierarchy.
Having said this, behaviors do not follow a hierarchy and can be used similar to classes. I'm actually so spoiled on behaviors that I rarely use classes anymore :)
05/19/2008 (5:46 am)
Joe, I believe that this "feature" is a consequence of hierarchical nature of class namespaces. In a hierarchy, each class can only have one parent. In this case, t2dStaticSprite and t2dTextObject are children classes of t2dsceneobject. By assigning a script class to both, you're essentially trying making the script class a child of both, violating the definition of a hierarchy.
Having said this, behaviors do not follow a hierarchy and can be used similar to classes. I'm actually so spoiled on behaviors that I rarely use classes anymore :)
#4
05/19/2008 (2:36 pm)
Thanks for the explanation Patrick, I was wondering why torquescript worked this way. I'm also a big fan of behaviors, they're so great.
Associate Phillip O'Shea
Violent Tulip