Android AndEngine-场景中所有纹理区域的一个纹理层;可能的

Android AndEngine-场景中所有纹理区域的一个纹理层;可能的,android,andengine,Android,Andengine,我注意到我可以为一个纹理区域保留一个图集,尽管我可以像精灵一样多次绘制同一区域。是否可以将所有纹理区域保留在场景中的一个纹理区域中 我的特殊情况是,我生成图像,而不是使用任何图像文件。我使用BaseBitMapTextureAtlassSourceDecorator执行此操作,并从IBitMapTextureAtlassSource生成区域。是。但是,一般来说,为了提高效率,您应该只创建最大宽度/高度为1024的地图集(顺便说一下,这些大小必须是2的幂) 另一方面,我发现使用BuildableB

我注意到我可以为一个纹理区域保留一个图集,尽管我可以像精灵一样多次绘制同一区域。是否可以将所有纹理区域保留在场景中的一个纹理区域中


我的特殊情况是,我生成图像,而不是使用任何图像文件。我使用BaseBitMapTextureAtlassSourceDecorator执行此操作,并从IBitMapTextureAtlassSource生成区域。

是。但是,一般来说,为了提高效率,您应该只创建最大宽度/高度为1024的地图集(顺便说一下,这些大小必须是2的幂)

另一方面,我发现使用BuildableBitmapTextureAtlas更容易。使用这种图集,您不必指定在图集中放置纹理的位置。我认为它也可以在一定程度上解决雪碧出血的问题(尽管不确定)。这是同样的想法真的。。。以下是我的项目中的一个示例:

BuildableBitmapTextureAtlas buttonAtlas = new BuildableBitmapTextureAtlas(getTextureManager(), 512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
model.moveLeftButtonTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(buttonAtlas, this, "moveleft_button.png");
model.moveRightButtonTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(buttonAtlas, this, "moveright_button.png");
model.handleBlockButtonTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(buttonAtlas, this, "handleblock_button.png");
model.restartButtonTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(buttonAtlas, this, "restart_button.png");

try{ buttonAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 1)); }
catch(Exception e){ e.printStackTrace(); }
buttonAtlas.load();

总之,atlas只保存您添加到其中的所有纹理。然后将该图集加载到内存中,以便快速检索这些纹理。然后,您可以使用纹理的单个实例来构建任意数量的独立精灵。

对于createFromAsset,它可以工作,但对于我的情况,我必须创建FromSource,因为我没有使用任何现有的图像文件,我正在生成位图源(IBitMattextureAtlasSource)。但是,有一种方法:BitMapTextureAtlastTextureRegionFactory.createFromSource(…)是的,这就是我要说的。由此创建的区域似乎不适用于BuildableBitmapTextureAtlas.Hmm。createFromSource(…)接受一个可构建的BitMapTextureAtlas源和一个IBitMattextureAtlasSource。这不是你需要的吗?但是你的回答很有帮助。我只是不能给它排名,因为我还没有那种特权。
BitmapTextureAtlasTextureRegionFactory.createFromSource(BuildableBitmapTextureAtlas atlas, IBitmapTextureAtlasSource source)