Image of transparent image libgdx

I used texture painting for 2 images, but the background image turns black. The original image is png and transparent. How can i solve this?

How to render the original image with transparency?

+6
source share
2 answers

Try the following:

spriteBatch.begin(); //background seaTexture = new Texture(px); Color c = spriteBatch.getColor(); spriteBatch.setColor(cr, cg, cb, 1f); //set alpha to 1 spriteBatch.draw(seaTexture, 0, 0, 480, 320); //foreground c = spriteBatch.getColor(); spriteBatch.setColor(cr, cg, cb, .3f);//set alpha to 0.3 spriteBatch.draw(blockTexture, 50, 100, 120, 120); spriteBatch.end(); 
+29
source

Try spritebatch.enableBlending() if you disabled it before. Should be enabled by default, though.

+1
source

Source: https://habr.com/ru/post/919387/


All Articles