LayerManager and Sprites

The LayerManager in MIDP 2.0 draws layers acording to their z-orden in the LayerManager object. Since a Sprite is a Layer, than it follows the same rules for being rendered.

But the basic theory about tile based games are that each row is drawn one by one, so sprites located lower at the screen are on top of other Sprites upper in the screen. This is usefull for giving life to the isometric view.

Is there a good way to rearrange the sprites so that sprites with greater Y location has a smaller z order? Do I have to manually remove the sprites and inserts them in the LayerManager in the correct order?

Did I make myself clear?

To use the LayerManager for this, yes you’d have to manually remove and add the Sprites.

But the LayerManager actually gives you rather little: I’d suggest you code your own with the behaviour you want. It sounds like you need to sort the list of Sprites each time you paint, but it’s easy to choose a sort algorithm that’s cheap if the list is already sorted or nearly sorted.

That’s what I imagined. Thanks. I will have to re-read my academic algorithms book. I just do not remember quick sort, bubble sort… eheh. I thought I would never need to reimplement those again… It’s good they are easy to implement…