2012-06-30 15 views
6

2 resim için doku çizimi kullandım, ancak arka plan resmi siyah oluyor. Kaynak resim png ve şeffaf. Bunu nasıl çözebilirim?libgdx texture image saydam hale getirme

Orijinal görüntüyü nasıl şeffaf hale getirebilirim?

cevap

1

Daha önce devre dışı bıraktıysanız, spritebatch.enableBlending()'u deneyin. Varsayılan olarak etkin olmalıdır.

29

Bu deneyin:

  spriteBatch.begin(); 
      //background 
      seaTexture = new Texture(px); 
      Color c = spriteBatch.getColor(); 
      spriteBatch.setColor(c.r, c.g, c.b, 1f); //set alpha to 1 
      spriteBatch.draw(seaTexture, 0, 0, 480, 320); 
      //foreground 
      c = spriteBatch.getColor(); 
      spriteBatch.setColor(c.r, c.g, c.b, .3f);//set alpha to 0.3 
      spriteBatch.draw(blockTexture, 50, 100, 120, 120); 

      spriteBatch.end(); 
+0

Bu hat 'Gdx.gl.glClear (GL20.GL_COLOR_BUFFER_BIT) birinci ekranı temizlemek için gerekli; başına alfa etkilerini görmek için 'spriteBatch.begin()' önce' [burada talimatlar] (https://github.com/libgdx/libgdx/wiki/Spritebatch ,-Textureregions ,-and-Sprites) – rockhammer

+1

Elbette bunu yapmalısınız. Sadece kodun en önemli kısmını gösterdim. – Nolesh

İlgili konular