简体   繁体   中英

LIBGDX Tiled Map not using transparency

I'm trying to draw trees on top of snow in a tiled map. However, when I draw my player sprite underneath the trees, the trees are not transparent and the sprite goes underneath white bits. I have added a transparency channel for the trees in gimp. I am using:

tiledMapRenderer.setView(cam);
        tiledMapRenderer.render();

I have tried using

Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); 

and batch.enableBlending(); to no prevail.

Check the follwing:

  1. Does your image file correctly define the transparency? (easy: check with any image viewer)
  2. Do you load your image into a Texture object that supports alpha? (easy: use default Texture constructor with FileHandle)

  3. Make sure all SpriteBatches you are using allow blending. (It's enabled by default and you did check that too)

  4. Are you drawing the image into a FrameBuffer? Make sure your FrameBuffer has an alpha channel. Also check how you are clearing the FrameBuffer before use - if you are using intermediate FrameBuffers, eventually you should clear them to be transparent (blank).

不用担心,在我将其导出到png之后,gimp显然并没有保持透明,因此我使用了ms paint,现在它是透明的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM