Object ordering is definitely not simple, as you are slowly discovering. :P
Printable View
Object ordering is definitely not simple, as you are slowly discovering. :P
You could attempt to just use the normal MMF "move behind object" thing.... but honestly you probably have to run the layer object sort action again. There's no way to just "sort one" because it needs to look at all the objects in order to know where to sort that one. What you're asking it to do is "Put this card into the proper arrangement in this blind deck of cards". MMF has no idea what to do. It needs to know all the other cards to make the proper action. But it's not like the layer object is storing all of the info for where every object is layered... The Layer object is merely running through the objects the one time and sorting them at that time. Then it throws away the sort information.
There must be some way to do this that works well in all runtimes? How do people manage order generally?
No matter what way you slice it, if you're trying to insert an object in between a bunch of other object layers, you'll need to first find the objects that either need to draw under it or over it. There's no way around that.
Say you have this:
O = objects over the one you want to place
U = objects under the one you want to place
V = object you want to place
OOOOOOOVUUUUUUUUUU
In order for you to tell MMF (or any program) "place V right here", the program needs to know where "here" is. You can't just "insert" it between the Os and Us, because there isn't a between.
It's like a shelf of books, and you're trying to stick a book in the middle where there's no space. All of the books need to be sorted in order to make room for the new one. (or at least you need to push over one side of the books to clear a spot for the middle)
You can't just stick an object where there is no "space" for it.
Also, Flash is on the way out. I really don't think you should bother exporting a game to it at this point.
But how do people go around this? I still don't feel it should be this much trouble just to display stuff in the right order. What exactly does the "Move behind" and "Move in front of object" events do to the "bookshelf"?
About Flash, it may be declining, but Flash is in fact the only area I still make any money at this point. I made over $1000 this month from my Flash games. It would like to go over more to mobile, but I find the lack of Box2D extension in those areas still extremely lacking. I am looking around for an alternative to develop for mobile, but I really hope MMF will get some mobile Box2D support, I feel that it needs to happen eventually, and sooner rather then later (it is already quite late).
Maybe it is better to use different layers for objects? The problem then is to handle collisions, but I think I remember you had some system for doing collisions with X and Y cordinates konidias that was not dependent on overlaps on same layer?