目前我正在使用libgdx 1.4.1在我的游戏的各个点都有不需要的纹理问题,我正在分享一个这样的问题的屏幕截图(黑色字符带有弹出退出)。在游戏中,我有彩色字符的纹理图集(spritesheet)而不是这些黑色字符。
发生的条件:
1. On ads loading(banner/interstitial admob ads).
2. In app purchase.
3. sometime on google leaderboard.
4. On resume after home button press(rarely).
5. On resume in case of exit (sometime if i commented assetmannage.dispose()).
问题。
1.Random texture any where.
2.black fonts/texture after resume
我的代码实现。 我正在使用assest manager类来加载所有纹理。
public void create() {
FileHandleResolver resolver=new InternalFileHandleResolver();
assetManager = new AssetManager(resolver);
Texture.setAssetManager(assetManager);
assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
Texture.setAssetManager(assetManager);
//loading fonts.............
for (int i = 1; i < 3; i++) {
int size=9*(1+i);
FreeTypeFontLoaderParameter fontParameterS=new FreeTypeFontLoaderParameter();
fontParameterS.fontFileName=Constants._strungFontPath;
fontParameterS.fontParameters.size=size;
fontParameterS.fontParameters.characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890\"!`?'.,;:|/@\\^$-%+=#_&";
assetManager.load("stungFont"+size+".ttf",BitmapFont.class,fontParameterS);
}
}
public void loadingResourceDuringSplash() {
//Loading some CSV,s
Pixmap pixmap=new Pixmap(20,20, Format.RGBA4444);
pixmap.setColor(1, 1, 1,1);
pixmap.fill();
blankTexture=new Texture(pixmap);
// pixmap.dispose();
loadAssetsINAssetManager();
}
private void loadAssetsINAssetManager() {
assetManager.load("img/Moles.atlas", TextureAtlas.class);
assetManager.load("img/tutorial.atlas", TextureAtlas.class);
assetManager.load("img/Main_BG.png", Texture.class);
assetManager.load("img/tree.png", Texture.class);
//some other file texture to..
}
public void render() {
super.render();
assetManager.update();
sleep();
}
@Override
public void dispose() {
super.dispose();
// assetManager.dispose(); // makes problem less frequent
// blankTexture.dispose();
// pointTexture.dispose();
}
@Override
public void resume() {
super.resume();
Texture.setAssetManager(assetManager);
loadAssetsINAssetManager();
assetManager.finishLoading();
}