I don't have experience doing what you're doing, but I'll make two points:
The ArrayOutOfBounds exception is typically caused when you modify object collections
outside of the update thread if the work you are doing is on another thread then you must invoke your sort code on the update thread like:
Using java Syntax Highlighting
mEngine.runOnUpdateThread(new Runnable() {
@Override
public void run() {
// do sorting stuff here.
});
Parsed in 0.031 seconds, using
GeSHi 1.0.8.4
I'm not sure that the z order is the way to layer your sprites, I'm pretty sure I've read around here that you can attach the entity/child by calling this variant of mScene.attachChild():
Using java Syntax Highlighting
public boolean attachChild(final IEntity pEntity, final int pIndex)
Parsed in 0.031 seconds, using
GeSHi 1.0.8.4
According to the java doc for the underlying ArrayList this is going to, you can squeeze elements in (front, back, or anywhere) which will (I assume) influence the drawing order. The Java doc:
void java.util.ArrayList.add(int index, IEntity object)
Inserts the specified object into this ArrayList at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this ArrayList, the object is added at the end.
You'll notice the bit I made bold suggests that no values are overwritten, but inserted before..
Again, I'm just guessing, so I could be wrong on all counts
