我正在尝试从已安装的 obb 扩展文件中加载纹理,但 AndEngine 无法打开此文件。那是我的代码:
BuildableBitmapTextureAtlas atlas = new BuildableBitmapTextureAtlas(textureManager, 2048, 2048, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath(obbManager.getMainRoot() + "/");
File file = new File(obbManager.getMainRoot() + "/background.png");
if (file.exists()) {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
background = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlas, this, "background.png");
这就是我在 Logcat 中看到的:
02-10 22:40:09.170: INFO/System.out(20962): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
02-10 22:40:09.180: ERROR/AndEngine(20962): Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: /mnt/obb/8d6d9efb8ab5fbfaa452d7ff7e8047c5/background.png
java.io.FileNotFoundException: /mnt/obb/8d6d9efb8ab5fbfaa452d7ff7e8047c5/background.png
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:315)
at android.content.res.AssetManager.open(AssetManager.java:289)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:48)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:39)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:140)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:132)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:128)
因此,该文件存在,但我仍然收到 FileNotFoundException。