2014-07-24 50 views
0

第二次加載我的andengine活動時,我的精靈(它們本身就是不同的顏色)都顯示爲黑盒子。這很奇怪,因爲通常這個問題是由於紋理圖集不夠大,但我試圖將圖集的大小加倍,並且這不起作用。所以這裏是相關的代碼,任何幫助將不勝感激!重新加載andengine而不是精靈的黑盒子

所以要把它放在那裏,我第一次加載我的遊戲,一切都很好,完美,但第二次,精靈顯示爲黑色。

我已經看到其他問題,其中的精靈出現黑盒子,但對我來說,他們第一次加載罰款,這不會發生其他問題,並在其他問題上給出的答案不適用於我(他們,阿特拉斯必須是兩個功率,和Atlas不夠大)

public void loadGameResources(){ 

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); 

    gameTextureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(), 512, 512, TextureOptions.BILINEAR); 

    blackTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "blacktile.png"); 
    greyTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "greytile.png"); 
    redTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "redtile.png"); 
    greenTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "greentile.png"); 
    Log.d(gameTextureAtlas+"","didn'tignore"); 
    loadFont(); 

    try{ 
     Log.d("LOPOLL","arrived"); 
     gameTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0)); 

     Log.d("boom","arrived"); 

     gameTextureAtlas.load(); 
     Log.d("gotHere","arrived"); 
    }catch(Exception e){ 
     Log.d("WrongPlace","arrived"); 
    } 

} 

(資源卸載方法)

public void unloadGameResources(){ 
    if(gameTextureAtlas !=null){ 
    gameTextureAtlas.unload(); 
    } 
    gameTextureAtlas = null; 

//  blackTile = null; 
//  greyTile = null; 
//  redTile = null; 
//  greenTile = null; 

    } 

,我評論的部分給予tiletextures空的理由價值在於這樣做是出於某種原因創建的ullexception錯誤,即使我認爲textureregions將被重新分配的活動重新加載活動時重新加載的活動調用loadgameresources()方法

+0

如果在離開活動時進入'設置活動'並離開它,則精靈不是框。也許這些信息可能有用? – user3287039

+0

夥計們幾乎只是暫停不會破壞它的活動,我如何讓它破壞活動? – user3287039

回答

0

得到了答案傢伙.. System.exit(代碼)確保活動正常退出。失望的堆棧溢出無法回答這個問題!