To safely remove a entity from scene on finish path modifier i recommend use EntityDetachRunnablePoolUpdateHandler.
1) Define variable on main class
private EntityDetachRunnablePoolUpdateHandler detachPoolHandler = new EntityDetachRunnablePoolUpdateHandler();
2) Register handler
getEngine().registerUpdateHandler(detachPoolHandler);
3) Add to onModifierFinished of LoopEntityModifier detaching of shape with use of EntityDetachRunnablePoolUpdateHandler
new LoopEntityModifier(new IEntityModifierListener() {
@Override
public void onModifierFinished(final IModifier<IEntity> pEntityModifier, final IEntity pEntity) {
EntityDetachRunnablePoolItem edrpi = detachPoolHandler.obtainPoolItem();
edrpi.set(entity, scene.getChild(0));
MainActivity.instance.detachPoolHandler.postPoolItem(edrpi);
visible = false;
}
}, 0, null, new SequenceEntityModifier(new ScaleModifier(0.2f, 1f, 0.1f)));
When the EntityDetachRunnablePoolUpdateHandler gets his next update, the entity is safely removed.