2011-11-16 42 views
0

我得到了一個額外的線條(即1像素)以及TextureRegions。這裏是我製作textureRegions的代碼。我也嘗試在紋理區域之間提供1像素的填充,但它不起作用。我的圖像的大小是132x24。在AndEngine中沿紋理區域獲取額外線條(Android)

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的所有邊上。

回答

1

我用的解決方法here擺脫那些時髦的線條。據我所知,它們只是某處填充不當的結果。我仍在努力理解爲什麼解決方案有效,但它做到了!

+0

我嘗試了這篇文章中的代碼,但仍然隨機獲取線條。 – Khawar

+1

查看另一種技術的鏈接。 Whalabi用透明png加載了整個紋理,然後在其上加載了所有的東西。也爲我工作,我喜歡它比擴展TextureFactory更好。 – jmcdale

+0

謝謝,我試過Whalabi的想法,它爲我工作。 – Khawar

0

我不使用AndEngine,但通常當這發生在我身上時,它是因爲我已經將OpenGL設置爲GL_NEAREST,它看起來需要目標像素的兩個像素來近似顏色。如果同樣的事情發生在你身上,它可能會看你的圖像的左側/右側...

嘗試使您的紋理的寬度/高度更小(不是實際的圖像大小,但這是你的尺寸告訴AndEngine)

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); 
+0

我試過了1像素的填充,但沒用。線條仍然隨機出現在精靈上。 – Khawar