繁体   English   中英

Pixmap圆圈边框未出现在libGDX html项目中

[英]Pixmap circle border doesn't appear in libGDX html project

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

html项目上没有边框

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

  1. 创建纹理

    Pixmap pixmap = new Pixmap(radius * 2 + 1, radius * 2 + 1, Format.RGBA8888); Pixmap.setBlending(Blending.None); pixmap.setColor(new Color(1,1,1,1)); pixmap.fillCircle(radius, radius, radius); pixmap.setColor(new Color(0, 0, 0, 0.6f); pixmap.fillCircle(radius, radius, radius - borderWidth); texture = new Texture(pixmap); 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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM