The Daily Click ::. Forums ::. Klik Coding Help ::. Object Z ordering
 

Post Reply  Post Oekaki 
 

Posted By Message

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
10th August, 2011 at 12:10:14 -

Hi All,

Wonder if anyone on here has some super clever way of solving a problem I have, without involving more objects to try and save on the active count.

I have a few copies of one object, all using the same engine code. I want to order them such that objects with a greater Y position are in front of objects with a lesser Y position.

Being lazy, I thought I could just test to see if an object collides with itself (this is the problem as altering the effect on the sprite depending on the condition shows that both objects are selected), if Y position of object > Y position of object move in front of itself.

And vice versa for the Y < Y condition. This does not work due to the selection problems mentioned above.

Looping through and selecting each object in turn is of course useless, becuase the object selection of the fixed value or a spread value selects a singular object in the conditions.

Any ideas? Any advice on referencing two objects would be a great help!

Hopefully thanks in advance

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
10th August, 2011 at 12:30:21 -

Pretty sure the Layer object has a "Sort by Y" action and is readily available to all

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
11th August, 2011 at 00:57:27 -

Do what Duncan taught!

 
lol

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
13th August, 2011 at 18:29:55 -

I would write a simple sort algorithm, but that's basically because I had no idea about Duncan's suggestion.

Isn't it that object can be referenced by a spread number somewhere in their values?

Save that number and the y position from the object, that list you can sort. And then do that bring to front action, starting with the object that has the lowest y score and bring the next one in front, etcetera. Or the other way around, depending on your program.

 
Image jenswa.neocities.org

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
14th August, 2011 at 11:37:11 -

Thanks everyone, with some careful event ordering the layer object Y sort is doing a grand job!

I thought i was going to have to write a loop as Jenswa suggested.



Edited by an Administrator

 
n/a
   

Post Reply



 



Advertisement

Worth A Click