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!
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.