Game Development Community

Alpha4: addToSceneGraph() resets sprite?

by Jason McIntosh · in Torque Game Builder · 02/01/2006 (4:10 pm) · 4 replies

I think the alpha4 release changed behavior of addToSceneGraph()/removeFromSceneGraph(). I'm not certain yet, but I think it resets all the attributes of the object, like layer and size (maybe rotation etc too?). Melv, can you confirm this please?

If it does, it would be very nice if that could be notated somewhere in the changelog or other docs so we could know about these silent but major changes. I've been chasing this strange behavior for a couple hours now after switching to alpha4 from alpha2. All my objects that change scenegraphs now need to be resized, put back into their layer, etc which really makes changing scenegraphs much more difficult to use since you very likely won't want everything to reset just to change scenegraphs.

I'm also having new troubles with my custom GUI system no longer working. I have no idea why yet, but I suspect there are more silent but major changes to the inner workings that I will soon discover...... I don't mind breaking interfaces and internal changes (it's alpha, early adopter, etc), but it would save a lot of time if these things could be documented. :) Maybe they are but I missed them in the changelog?

#1
02/01/2006 (4:30 pm)
Well, it does reset the attributes... but it shouldn't. I will fix this as soon as I can and post the solution. Without more info about the gui stuff, I can't help you there.

The only real major change to t2dSceneObject is the addition of persistent fields for all object properties. So, when an object is created you can do things like:
new t2dSceneObject() { scenegraph = t2dscene; position = "10 20"; size = "10 10"; };
This was a necessary addition for the level editor and saving objects.

I would imagine that the gui system problems are related to this (as are the addToScene problems).
#2
02/01/2006 (5:36 pm)
Ah, thanks for the info, Adam. Good idea having those properties available for more compact definitions. :)
#3
02/02/2006 (9:47 am)
Alright. Quick fix. Just add this to the end of t2dSceneGraph::removeFromScene on about line 700 of t2dSceneGraph.cc:
pSceneObject2D->updateFieldSelectedValues();

Or, as a temporary fix, if you don't want to make engine changes, you can call that same function from script after you remove the object from the scene, but before you add it to the new one. So:
sceneObject.removeFromScene();
   sceneObject.updateFieldSelectedValues();
   sceneObject.addToScene(newScene);

I still have to test this to make sure there are no funny side effects, but it should work. Let me know if you have any problems. This will definitely be fixed in the next release (probably sooner than you think).
#4
02/02/2006 (7:10 pm)
Thanks Adam, I'll give that a try.

And I do hope there will be an alpha 5 soon which fixes a lot of these new issues and updates the docs. I guess moving to TGE 1.4 and creating the new editor brought in a lot of changes. Great work (everyone) getting these bugs stomped quickly.