Increasing the width of line drawn using Shape Renderer in LibGDX

后端 未结 2 740
太阳男子
太阳男子 2020-12-20 19:16

I am drawing a line using Shape Renderer in LibGDX and i am using Orthographic Camera in my code, so to increase the width i used

camera = new OrthographicCa         


        
相关标签:
2条回答
  • 2020-12-20 19:57

    As you can see here:
    libgdx Shaperenderer line .. How to draw line with a specific width
    And here:
    Libgdx gl10.glLineWidth()
    And here:
    Why Libgdx Gdx.gl10.glLineWidth(width); does not react to change projection properities

    Playing with the line width in the shaperenderer isn't the best way to do what you want to achieve.

    Try using a 1x1 white TextureRegion (you can change the color the Batch draws it with later), and draw it with the width and height that you desire:

    batch.draw(region, x, y, width, height);
    
    0 讨论(0)
  • 2020-12-20 19:59

    ShapeRenderer has the method rectLine that is intended to be used to draw thick lines. It draws a rotated filled rectangle with the smaller opposite sides centered on the points passed to it (as coordinates or as Vector2 objects). The method has the parameter width to set the line width.

    You can see the documentation here

    Example:

    shapeRenderer.rectLine(new Vector2(x1,y1),new Vector2(x2,y2),lineWidth);
    
    0 讨论(0)
提交回复
热议问题