Game Development Community

Setlayerdraworder question

by Gellyware · in Torque Game Builder · 09/09/2006 (2:36 pm) · 4 replies

How does set layer draw order work exactly? I can't seem to get it to do anything.

I'm trying the following:


// set the drawing order of the coin
function coin::setOrder(%this, %order)
{
%sg = sceneWindow2D.getSceneGraph();

echo("CHANGING LAYER DRAWING ORDER:"@%order);

%sg.setLayerDrawOrder(%this, FRONT);

for(%i=0; %i < %order; %i++)
%sg.setLayerDrawOrder(%this, FORWARD);
}


I used a loop to randomly set the draw order of the 'coins' and they don't seem to be changing their layer drawing order. Using "FRONT" isntead of FRONT doesn't do anything either.

#1
09/09/2006 (2:52 pm)
I just tested draw order to confirm and it worked fine for me. I just opened TGB, created and named three different obejcts, and in the console did exactly what you just did:

$sg = sceneWindow2D.getSceneGraph();

$sg.setLayerDrawOrder( thing1, FRONT );
$sg.setLayerDrawOrder( thing2, FORWARD );
$sg.setLayerDrawOrder( thing2, FORWARD );

This moved thing1, which was in the back of layer 0, to the front of layer 0, then moved thing 2, which was now in the back of layer 0, in front of thing3 and then in front of thing1.

Have you tried this?
#2
09/09/2006 (3:07 pm)
Hm,

I tried this:

function coin::moveForward(%this)
{
%sg = sceneWindow2D.getSceneGraph();
%sg.setLayerDrawOrder(%this, "FORWARD");
}

function coin::moveBackward(%this)
{
%sg = sceneWindow2D.getSceneGraph();
%sg.setLayerDrawOrder(%this, "BACKWARD");
}


and calling those functions from the console seem to work fine.

Maybe there is an issue with it looping through the
%sg.setLayerDrawOrder(%this, "FORWARD");

???


Could you simulate the same thing with say 40 objects overlaid over one another using that original function above?
#3
09/09/2006 (3:09 pm)
Actually, scratch that! I just figured out the problem. Moving it to the "FRONT" and moving it "FORWARD" doesnt make sense , since it is at the FRONT.

Changing FRONT to say BACK works. I.e.

// set the drawing order of the coin
function coin::setOrder(%this, %order)
{
%sg = sceneWindow2D.getSceneGraph();

echo("CHANGING LAYER DRAWING ORDER:"@%order);

%sg.setLayerDrawOrder(%this, "BACK");

for(%i=0; %i < %order; %i++)
%sg.setLayerDrawOrder(%this, "FORWARD");
}


Thanks for the help though!
#4
09/09/2006 (3:17 pm)
No problem. =)