我正在使用 Libgdx。我想在我的游戏中使用 pixmap 模拟雾,但是在生成"fogless"
圆圈时遇到了问题。首先,我制作了一个像素图,用黑色填充(它有点透明)。填充后我想在上面画一个实心圆,但结果不是我预期的。
this.pixmap = new Pixmap(640, 640, Format.LuminanceAlpha);
Pixmap.setBlending(Blending.None); // disable Blending
this.pixmap.setColor(0, 0, 0, 0.9f);
this.pixmap.fill();
//this.pixmap.setColor(0, 0, 0, 0);
this.pixmap.fillCircle(200, 200, 100);
this.pixmapTexture = new Texture(pixmap, Format.LuminanceAlpha, false);
在程序render()
public void render() {
mapRenderer.render();
batch.begin();
batch.draw(pixmapTexture, 0, 0);
batch.end();
}
如果我使用格式。Alpha 在创建像素图和纹理时,我没有看到更半透明的圆圈。
这是我的问题:
有人可以帮我吗?我应该怎么做,我应该在绘制一个完全透明的圆圈之前初始化什么?谢谢。
更新 我找到了我的问题的答案。我必须禁用混合以避免问题。
现在我的代码:
FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, 620, 620, false);
Texture tex = EnemyOnRadar.assetManager.get("data/sugar.png", Texture.class);
batch.begin();
// others
batch.end();
fbo.begin();
batch.setColor(1,1,1,0.7f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw( tex, 100, 100);
batch.end();
fbo.end();
但我没有看到圆圈(这是一个 png 图像,代表透明 bg,白色填充圆圈)。