How to change sprite layer in andengine

How to change a sprite layer at runtime in render mode?

+5
source share
2 answers

It depends on what you understand by changing the layer. If you mean the z index of the object, then you can use entity.setZIndex (int) , and you need to call parent.sortChildren () manually for the parent of your sprite.

If, by changing the layer, you mean separation from one parent and binding to another parent, then this is another problem.

+5
source

. zorder sortChidren setZOrder, (Scene Entitys).

, .

@Override
protected void onDrawChildren(GL10 pGL, Camera pCamera) {
    getParent().sortChildren();
    super.onDrawChildren(pGL, pCamera);
}

Z- sprite.setZOrder(order ++), , , .

, , . ( )

, setZOrder (...) sortChildren /, , zorder , setZOrder z 3D-. , . ( andengine z mZIndex Entity) , , .

, . , , .

+2

All Articles