我用Andengine开发了一款游戏!它有100张照片(约15mb)。当我运行这个应用程序时,黑屏大约10秒钟。我想在装载其他100张图像时装鞋图片。
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 :(得分:0)
我添加了我的类来加载set image。
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() {
}
}