Sorry if the title is confusing, I'll try to explain. I have a game with 63x32 isometric grid in which the player moves around units (sprites).
The sprites (Active Objects) have a Y value/Y-position, and what I want is to make a unit with a higher Y value (i.e. closer to the bottom of the screen) to be Ordered/put on top of a sprite with lesser Y value.
In other words, I don't want a sprite to have his head covered by the feet of the sprite behind him. I don't want units with Y position lower than tree-sprites to be shown in front of the trees either.
I've tried for two days to make this work. I've tried using Y-position, Alternate Values based on Y-position, and extensions that either crash MMF or don't work.
I have a legal MMF2 Dev version so if any of you guys know of any extensions that might be used to sort this out I'd be grateful too.
My problem is related to get multiple units of the same Active Object (e.g. "Player") to be Ordered differently, and to each other. But I can't really say "Put Player in front of Player if Y(Player)>Y(Player).
I need something that says "Take everything on Y-value xxx and put them infront of everything at lesser Yvalues".
Originally Posted by phanto
"Put Player in front of Player if Y(Player)>Y(Player).
Because I think that's the way you should do it.
Since you know all the y coordinates of the objects you should use these together with an alternate value.
The one with the lowest y value should be on top of all, right? So the one with the highest y value should be on the back, try sorting the objects from the one that's at the back to the front. Use an alternative value to store a 0 for the object at the back and store the last number in the one belonging to the front on top of every other object.
Once sorted, you can loop through the list and bring each object to the front. The first object from the list (lowest alternate value: 0) should be at the back and when reaching the last object from the list (highest alternate value) should be on front, because it's brought the the front as last and is on top of every other object.
The only difficult thing is sorting the list but perhaps MMF2 has some kind of built in feature for this and with sorting I mean putting the right value in the alternate value.
A little example with three objects, they should be numbered 0, 1 and 2 in the alternate value.
0 will be brought to front, then 1 will be brought to front and is in front of 0, last 2 will be brought to front and is in front of 0 and 1.
So after sorting, bring to front will do your job. This is basically sorting sprites by z-order (where the z-order depends on the y-axis, search the internet for more information).
PS: At first when I read the topic of this post, I thought you wanted to order sprite from someone.