Game Development Community

Superclass automatically getting erased by editor on save

by john m ingato · in Torque Game Builder · 11/08/2009 (12:49 am) · 8 replies

Hi. I am using TGB and have not modified the source at all. I created a datablock that I've been using successfully with my project till now. this is the datablock I created

datablock t2dSceneObjectDatablock(rotatingBlockConfig)
{
Layer = 1;
Size = "10 10";
class = "rotatingBlock";
superclass = "specialBlock";
collisionActiveSend = true;
collisionActiveReceive = true;
collisionPhysicsSend = false;
collisionPhysicsReceive = false;
CollisionCallback = true;
};

Everything seemed to be working fine till a few days ago. now, for some odd reason, I pick the datablock from the drop down and it gives the object the proper setting. class = rotatingBlock and superclass = specialBlock. I test it out in game and it does not work. I open it again in the editor and check the onject and the superclass is blank. I type it in manually and save and the same exact thing happenes. The superclass is blank when I reopen it.

I've been using this datablock throughout my project with no issues so if I play an earlier level that used it, the objects worked as they should, but if I open that same level again in the editor, make no changes, and save it. The objects using that datablock no longer work correctly. I open that level again and surprise surprise, blank superclass.

Anybody have any idea what would cause something like this? It just started happening out of no where.


Thanks for taking the time to read this

-John

#1
11/08/2009 (12:57 am)
Are you seeing any console errors? You cannot use the same script class on two different base class objects, for example superClass = "rotatingBlock" cannot be used on a t2dSceneObject *and* a t2dStaticSprite. The same thing goes for regular ol' class as well.
#2
11/08/2009 (2:00 am)
I think you hit the nail on the head! I had an animated sprite and a static sprite both using the same superclass. I removed the animated sprite and the static sprites seemed to work as they should. Man, that was driving me nuts! The question now is how can I assign them the same superclass and get it to work? Is it possible?

Thanks for the quick response :)

**EDIT - I found a quick work around. All I did was take the static sprites I was using and created one frame animations and used those instead. Now they are all of the same base class.

Thanks for the help again. I would have never solved this!
#3
11/14/2009 (2:57 am)
Ok, the problem is back....kind of. That last trick seemed to work for that level. But I just noticed a new problem. My previous levels used static sprites with the same superclass. This level uses Animated Sprites. If I open the game and go right to the new level it works fine, but if I open one of my previous levels first, then open the new level it does not work. It then has the same issue it used to have. It's as if the static sprites on the previous level that used that common superclass are still there, causing the earlier problem. Here's the code I'm using the loadthe next level.

function loaduplevel(%levelnum)
{
alxStop($levelmusic);
sceneWindow2D.endLevel(); //if we are in a level, end it
popGUIs();
%thelevel = "LEVEL" @ %levelnum;
%levelFile = %thelevel.levelFile;

%level=expandFilename("~/data/levels/" @ %levelFile @ ".t2d");
if( isFile( %level ) || isFile( %levelFile @ ".dso")) {
sceneWindow2D.loadLevel(%level);
}
$thescenegraph = sceneWindow2D.getSceneGraph();
Canvas.hidecursor();
initializeLevel(%thelevel);
}

Is there something else I need to do? I don't understand why there would be any trace of these objects once you end the level. They're not on the screen at all.

Thanks again

-John
#4
11/14/2009 (11:04 am)
I personally have completely abandoned of datablocks technology, since they work/don't work.

Instead, i set the class to an object, and add onAdd() method to that class where i set all the attributes.
#5
11/14/2009 (2:43 pm)
Well, the problem doesn't seem to be with the datablocks, but rather with having the same superclass assigned to different types of objects, even though they are in different levels, which I don't get.
#6
11/14/2009 (5:05 pm)
The trouble is that the "binding" remains on t2dAnimatedSprite/t2dStaticSprite (depending on which class of object uses it first).

This is one of the reasons why behaviors were created.

Unfortunately you don't have many options if you didn't want to move the methods to a behavior. The only thing that I can think of, though not very good at all, is to duplicate the script class methods for different types of objects:
function MyClassSS::onCollision( ... )
{
   // ...
}

function MyClassAS::onCollision( ... )
{
   MyClassSS::onCollision( ... )
}
#7
11/14/2009 (5:57 pm)
Watch out for naming convention in TGB - there is no one! You 'll have to invent your own. But you should have one.

The thing that also wont work is (for eg.) if you name a imageMap "enemyZombie", you cant use class or superClass named "enemyZombie" anywhere in your game. That also applies for naming animated sprites, scrollers... and maybe even datablocks.
#8
11/14/2009 (8:38 pm)
cool, Thanks again! Now it makes sense.