2013-03-08 47 views
0

IA費Andengine如何使一個孩子的父母背後

fee = new AnimatedSprite(0, 463, this.mFairyTextureRegion); 

我想一個孩子跟着費我用這個代碼,但粒子系統始終是前

mScene.attachChild(fee); 
//mScene.getLastChild().attachChild(particleSystem);  
fee.attachChild(particleSystem); 
fee.setZIndex(fee.getZIndex()+1); 
particleSystem.setZIndex(particleSystem.getZIndex()-1); 
//fee.sortChildren(); 
mScene.sortChildren(); 

如何使一個孩子的父母背後費用?

回答

1

我按照此處描述的改變andengine自身管理這個,

http://www.andengine.org/forums/tutorials/drawing-children-behind-it-parent-not-possible-with-zindex-t4810.html

我更改類的順序,

\ AndEngine的\ src \組織\ anddev \ andengine \實體\ IEntity的.java

protected void onManagedDraw(final GL10 pGL, final Camera pCamera) { 
    pGL.glPushMatrix(); 
    { 
     this.onApplyTransformations(pGL); 
     //Saw these next two araound 
     this.onDrawChildren(pGL, pCamera); //Draw children first 
     this.doDraw(pGL, pCamera); //Then the parent 


    } 
    pGL.glPopMatrix(); 

}

我t可能是爲這個類添加一個公共標誌的一個想法,所以你可以切換孩子在父母的前面/後面繪製。請注意,這是針對GLES 1的,我不知道是否在GLES2中引入了更好的解決方案。