I want attach sprites in different layers. I do this:
final Scene scene = new Scene();
for(int i = 0; i < NUMBER_OF_LAYERS; i++) {
scene.attachChild(new Entity());
}
...
...
scene.attachChild(
getSprite(),1);
LogCat gives out an error:
0
2-29 10:30:10.489: E/AndroidRuntime(17018): java.lang.IllegalStateException: pEntity already has a parent!
Why so occurs? And how attach sprites in different layers?
The error message is saying that the entity you want to attach to scene already has another parent so either you have to detach it or you can clone the entity and then attach to scene each time
to detech the code is
and for clone it is simply