gpt4 book ai didi

java - libGDX html 项目中未出现像素图圆形边框

转载 作者:太空宇宙 更新时间:2023-11-04 14:45:16 29 4
gpt4 key购买 nike

我正在使用 libGDX 编写我的第一个项目,目前正在尝试在背景顶部绘制一个带有不透明边框的透明圆圈。它在 Android 和桌面项目中按预期工作。但是,html 项目不会渲染圆的边框。

no border on the html project

圆圈是用像素图创建的纹理。由于无法为drawCircle方法设置笔划宽度(为什么没有?;请参阅http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Pixmap.html#drawCircle-int-int-int-),我将边框绘制为filledCircle,并在其顶部绘制另一个圆圈:

  1. 创建纹理

    Pixmap pixmap = new Pixmap(半径 * 2 + 1, 半径 * 2 + 1, Format.RGBA8888);
    Pixmap.setBlending(Blending.None);
    pixmap.setColor(new Color(1,1,1,1));
    pixmap.fillCircle(半径,半径,半径);
    pixmap.setColor(新颜色(0, 0, 0, 0.6f);
    pixmap.fillCircle(半径, 半径, 半径 - borderWidth);
    纹理=新纹理(像素图);
    texture.setFilter(TextureFilter.Linear,TextureFilter.Linear);
    pixmap.dispose();

  2. 绘图

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    // tell the camera to update its matrices.
    camera.update();
    game.spriteBatch.setProjectionMatrix(camera.combined);

    // begin the drawing process
    game.spriteBatch.begin();
    drawBackground();

    //circle gets drawn here
    game.spriteBatch.draw(texture, 50, 50);

    //end drawing process
    game.spriteBatch.end();

有什么想法吗?

编辑:在 Ubuntu 14.04 上的 Chrome (35.0.1916.153) 和 Firefox (30.0) 上进行了测试。有人可以重现这个问题吗?

最佳答案

您需要在绘制圆之前禁用混合:

pixmap.setBlending(Pixmap.Blending.None);
pixmap.fillCircle(radius, radius, radius);

关于java - libGDX html 项目中未出现像素图圆形边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24469381/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com