在AndEngine(Android)中沿着TextureRegion获取额外的行

时间:2011-11-16 11:13:28

标签: android box2d andengine

我得到一条额外的线(即1个像素)以及TextureRegions。这是我编写textureRegions的代码。我还尝试在TextureRegions之间提供1像素填充,但它不起作用。我的图片大小是132x24。

    this.txAt_Paddles = new BitmapTextureAtlas(512, 64,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
    this.txRg_paddle_left = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.txAt_Paddles, this, "paddle_left.png", 0,0);
    this.txRg_paddle_right = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.txAt_Paddles, this, "paddle_right.png", 0,24);
    this.mEngine.getTextureManager().loadTexture(this.txAt_Paddles);    

任何人都可以指出我为什么在不同的TextureRegions的不同侧面获得这些线的共鸣。这些线不在TextureRegions的所有边上。

3 个答案:

答案 0 :(得分:1)

我使用了解决方法here来摆脱那些时髦的界限。据我所知,它们只是某个地方填充不当的结果。我仍在努力理解为什么解决方案有效,但确实如此!

答案 1 :(得分:0)

我不使用AndEngine,但通常当我发生这种情况时,因为我将OpenGL设置为GL_NEAREST,它看起来像目标像素两侧的两个像素来接近颜色。如果发生同样的事情,可能会向你的图像左侧/右侧看远......

尝试使纹理的宽度/高度更小(不是实际的图像大小,但是这个大小是你告诉AndEngine的)

答案 2 :(得分:0)

您需要使用至少为1的填充。 我衷心建议您使用BuildableTextureAtlas。

这里是代码

 BuildableBitmapTextureAtlas text =  new BuildableBitmapTextureAtlas(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
  //note: no warring of positioning
 TextureRegionFactory.createFromAsset(text, this, "my image");
 [...]
 try 
    {
        text.build(new BlackPawnTextureBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(2));
    } catch (final TextureAtlasSourcePackingException e) {
        Debug.e(e);
    }

 this.mEngine.getTextureManager().loadTextures(this.mBuildableTexture);