【发布时间】:2014-01-23 03:58:59
【问题描述】:
我在 andEngine 中的纹理有问题
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback)
throws Exception {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
mTextureAtlas = new BuildableBitmapTextureAtlas(getTextureManager(),
480, 800);
fruitTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(mTextureAtlas, this, "fruitsprites.png");
fruitBG = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
mTextureAtlas, this, "gamebg.png");
try {
mTextureAtlas
.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(
0, 1, 1));
} catch (TextureAtlasBuilderException e) {
e.printStackTrace();
}
mTextureAtlas.load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
// TODO Auto-generated method stub
}
这会导致我的整个纹理图集出现在屏幕上;在我的 S4 上,纹理不断闪烁,并且纹理上下颠倒 - 看起来图像被部分切成三角形。
在模拟器上,整个贴图图集的内容都显示出来了,屏幕不闪烁,但是贴图是上下颠倒的。
另外fruitBGSprite.setVisible(true); 只是让纹理完全不可见(但屏幕不会闪烁)我现在的目标是只设置 1 个纹理作为我的背景。
【问题讨论】:
-
加载你的纹理图集,即mTextureAtlas.load();这条线不见了
-
我确实在
pOnCreateResourcesCallback.onCreateResourcesFinished();之前加载了altas -
您在不同的区域使用相同的纹理(即fruitTextureRegion 和fruitBG)。检查一下。尝试使用不同的纹理
标签: android opengl-es andengine