2012-06-30 5 views
6

2 개의 이미지에 텍스처 그리기를 사용했지만 배경 그림이 검은 색이됩니다. 원본 그림은 png이며 투명합니다. 어떻게 해결할 수 있을까요?libgdx 텍스처 이미지 transparent 렌더링

원본 이미지를 투명도로 어떻게 렌더링합니까?

답변

1

이전에 비활성화 한 경우 spritebatch.enableBlending()을 시도하십시오. 그래도 기본적으로 사용하도록 설정해야합니다.

29

이 시도 :

  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

나는이 라인'Gdx.gl.glClear (GL20.GL_COLOR_BUFFER_BIT) 먼저 화면을 취소하는 데 필요한, 당 알파 효과를 볼 수'spriteBatch.begin()'전' [지침은 여기] (https://github.com/libgdx/libgdx/wiki/Spritebatch,-Textureregions,-and-Sprites) – rockhammer

+1

물론이 작업을 수행해야합니다. 방금 코드의 가장 중요한 부분을 보여주었습니다. – Nolesh