【发布时间】:2014-01-21 08:31:38
【问题描述】:
我在动态加载纹理时遇到问题。
当用户双击屏幕时,背景和其他精灵会发生变化。没有产生错误,但有时纹理被清除并且新纹理没有加载。
这是我最初的 onCreateResource
ITextureRegion BackgroundTextureRegion;
BitmapTextureAtlas MainTexture1;
//Initiate Textures
MainTexture1 = new BitmapTextureAtlas(this.getTextureManager(),1000,1000, TextureOptions.BILINEAR);
//Clear Textures
MainTexture1.addEmptyTextureAtlasSource(0, 0, 1000,1000);
//Assign Image Files to TextureRegions
BackgroundTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(MainTexture1, this, "Evening.jpg",0,0);
//Loading the Main Texture to memory
MainTexture1.load();
在此之前没有问题。在此之后,当用户双击或滑动背景时,我会动态更改纹理。代码如下:
MainTexture1.clearTextureAtlasSources();
MainTexture1.addEmptyTextureAtlasSource(0, 0, 1000,1000);
BitmapTextureAtlasTextureRegionFactory.createFromAsset(MainTexture1, this, "WinterNight.jpg",0,0);
这通常会改变纹理,我会得到想要的结果。但在某些设备(例如三星 Tab 2)中,10 次中有 1 次 MainTexture1 被清除但未加载新图像。
所以它只是给出了一个黑屏,我该如何纠正这个问题?
【问题讨论】:
-
你应该重新加载纹理吗?
-
你的意思是 MainTexture1.load();再次?试过了。现在问题不像以前那样经常出现了。但仍然有 20 次中有 1 次变黑。谢谢。
-
你在 LogCat 中没有例外吗? Andengine 有时会隐藏它。
-
我的一个设备没有显示任何问题,问题出在其他一些设备(例如三星 tab2)现在我正在安装驱动程序以查看 logcat
-
No Logcat error found,没有错误,精灵只是不可见,如果我们采取任何设置或菜单并关闭它,精灵就会重新出现。