我用纹理绘制了2张图片,但是背景图片变成了黑色。源图片是png格式的,并且是透明的。我该如何解决这个问题?
如何渲染具有透明度的原始图像?
发布于 2012-10-25 23:01:23
试试这个:
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();
发布于 2012-06-30 15:29:21
如果您以前禁用过spritebatch.enableBlending()
,请尝试使用它。不过,默认情况下应启用。
https://stackoverflow.com/questions/11273467
复制