我正在使用Libgdx。 我想使用pixmap在我的遊戲中模擬霧,但在生成"fogless"
圈時遇到問題。首先,我製作一個像素圖,充滿黑色(它透明一點點)。填充後,我想繪製一個實心的圓圈,但結果並不是我所期望的。在libgdx中使用filledcircle和pixmap
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);
在程序渲染()
public void render() {
mapRenderer.render();
batch.begin();
batch.draw(pixmapTexture, 0, 0);
batch.end();
}
如果我使用的格式。 Alpha創建Pixmap和紋理時,我都看不到更加半透明的圓。
這裏是我的問題:
有人能幫助我嗎?我該怎麼做,我應該先畫出一個完整的透明圓圈?謝謝。
UPDATE 我找到了我的問題的答案。我必須禁用混合以避免該問題。現在
我的代碼:
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,白色實心圓)。
我更新我的回答看看。如果您對此有任何疑問,請更新此問題,而不是發佈答案。如果你嘗試我給你的代碼,但它不起作用更新問題,粘貼代碼並讓我知道輸出是什麼。所以我和其他人可以幫助你。謝謝 – Springrbua
另一個鏈接:http://stackoverflow.com/questions/14729961/ambiguous-results-with-frame-buffers-in-libgdx – Springrbua
你現在怎麼做?你是否在使用PixMap的混合功能被禁用?或者你使用我建議的FBO解決方案嗎? – Springrbua