Game Development Community

Sub Layering

by Aditya Kulkarni · in Torque Game Builder · 05/24/2010 (6:41 am) · 7 replies

'setLayer' sets the object layer in global space. Suppose I have 2 objects 'within the same layer', I need to change it so that the recently added object goes below the first object.

TGB has 'Back/Forward' in the Scene Object section which lets me do this. What would be the script function for it?

#1
05/24/2010 (6:54 am)
I have run into this as well. Luckily, it hasn't hurt my game logic to move offending objects into a lower layer. But it would be nice to be able to "pushtofront" or "pushtoback" within a layer, via script.
#2
05/25/2010 (4:37 pm)
Another solution is to clone the lower object and delete the older one so that the new one is at the top of the stack. It could cause problems if you're referencing it in script explicitly, but otherwise it'd work.
#3
05/25/2010 (8:12 pm)
Daniel, that's a clever solution.
#4
05/26/2010 (6:37 am)
Quote:But it would be nice to be able to "pushtofront" or "pushtoback" within a layer, via script.
You can and it's been in there since the very first release. Look at the Scene Graph Methods, specifically setLayerDrawOrder and setSceneDrawOrder.

The commands are "FRONT", "BACK", "FORWARD" & "BACKWARD".

The "scene" draw-order command operations on an object and moves it forward but may adjust the objects layer (if needed to make the command happen) but won't if it's not necessary. The "layer" draw-order never adjusts the objects layer and changes the draw-order only. This means you can move the draw-order front/back/forward/backward for all of the scene or within the current layer that the object exists.

Hope this helps,

Melv.
#5
05/26/2010 (6:45 am)
Doesn't work.

<input> (0): Unknown command setLayerDrawOrder.

I did a dump on my sceneobject (static sprite). It has setLayer(), but no setLayerDrawOrder().
#6
05/26/2010 (7:44 am)
If you spent a little more time reading my post you'd see I quite clearly state "Scene Graph Methods". That'd be the t2dSceneGraph.

This is a scene-wide command.
#7
05/26/2010 (9:45 pm)
Ok, awesome.

Thanks for the response melv.