在安德林(Android)的纹理区域获得额外线条

在安德林(Android)的纹理区域获得额外线条,android,box2d,andengine,Android,Box2d,Andengine,我得到一条额外的线(即1像素)以及纹理区域。这是我制作纹理区域的代码。我还尝试在纹理区域之间添加1像素的填充,但没有成功。我的图像大小是132x24 this.txAt_Paddles = new BitmapTextureAtlas(512, 64,TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.txRg_paddle_left = BitmapTextureAtlasTextureRegionFactory.createFrom

我得到一条额外的线(即1像素)以及纹理区域。这是我制作纹理区域的代码。我还尝试在纹理区域之间添加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);    

有人能指出为什么我在不同的纹理区域的不同侧面得到这些线条的原因吗。这些线条并不在纹理区域的所有侧面。

我不使用AndEngine,但通常情况下,当这种情况发生在我身上时,它是因为我已将OpenGL设置为“最近的”,看起来需要目标像素两侧的两个像素来近似颜色。如果同样的事情发生在你身上,它可能会朝着你图像的左/右远处看


尝试将纹理的宽度/高度变小(不是实际的图像大小,而是您告诉AndEngine的这个大小)

您需要使用至少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);
BuildableBitmapTextureAtlas text=新的BuildableBitmapTextureAtlas(512,512,TextureOptions.BILINEAR\u premultiplylpha);
//注:无需进行定位
createFromAsset(文本,这是“我的图像”);
[...]
尝试
{
构建(新BlackPawnTextureRebuilder(2));
}捕获(最终纹理LassourcePackingE异常){
e(e);
}
this.mEngine.getTextureManager().loadTextures(this.mBuildableTexture);

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

我在那篇文章中尝试了代码,但仍然随机获得了行。再次查看链接,了解其他技术。Whalabi用一个透明的png加载了整个纹理,然后加载了上面的所有内容。对我来说也很有用,我喜欢它,而不是扩展TextureFactory。我尝试过填充1像素,但没有用。这些线条仍然随机出现在精灵上。