2013-03-21 67 views
0

我開發了Andengine遊戲!它有100張照片(約15mb)。當我運行這個應用程序,它約10秒黑屏。當其他100張圖像加載時,我想裝入圖像。Andengine載入中等待時間

public void onLoadResources() { 

     for(i=0;i<100;i++) 
     { 
      textCircle[i]=new Texture(1024,512,TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
      textRegCircle[i] = TextureRegionFactory.createFromAsset(textCircle[i], this, "circlesBlue/"+i+".jpg", 0, 0); 
      mEngine.getTextureManager().loadTexture(textCircle[i]); 

     } 

回答

0

我添加了我的班加載設置圖像。

public class Game extends BaseGameActivity { 

private Scene dScene; 
private TextureRegion dLoadingRegion; 

Handler dHandler = new Handler() { 
    public void handleMessage(android.os.Message msg) { 
     switch (msg.what) { 
     case 0: 
      setYourSceneData(); 
      break; 
     } 
    }; 
}; 

@Override 
public Engine onLoadEngine() { 
    return null; 
} 

public void onLoadResources() { 
    BitmapTextureAtlas BitmapTextureAtlas = new BitmapTextureAtlas(512, 
      512, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
    dLoadingRegion = BitmapTextureAtlasTextureRegionFactory 
      .createFromAsset(BitmapTextureAtlas, this, 
        "your loading image path", 0, 0); 
    getTextureManager().loadTextures(BitmapTextureAtlas); 
} 

private void loadOtherGameGraphics() { 
    // here load your other region 
      for(i=0;i<100;i++) 
      { 
       textCircle[i]=new Texture(1024,512,TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
       textRegCircle[i] = TextureRegionFactory.createFromAsset(textCircle[i], this, "circlesBlue/"+i+".jpg", 0, 0); 
       mEngine.getTextureManager().loadTexture(textCircle[i]); 

      } 
} 

@Override 
public Scene onLoadScene() { 
    dScene = new Scene(); 
    dScene.attachChild(new Sprite(0, 0, Helper.CAMERA_WIDTH, 
      Helper.CAMERA_HEIGHT, dLoadingRegion)); 
    new Thread(new Runnable() { 
     @Override 
     public void run() { 
      loadOtherGameGraphics(); 
      dHandler.sendEmptyMessage(0); 
     } 
    }).start(); 
    return dScene; 
} 

public void setYourSceneData() { 
    // here set your game data 
    // and remove your loading image 
} 

@Override 
public void onLoadComplete() { 

} 

}