在LibGDX中增加使用Shape Renderer绘制的线条的宽度 [英] Increasing the width of line drawn using Shape Renderer in LibGDX

查看:193
本文介绍了在LibGDX中增加使用Shape Renderer绘制的线条的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在LibGDX中使用Shape Renderer绘制了一条线,并且在代码中使用了Orthographic Camera,所以增加了我使用的宽度

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 OrthographicCamera();
int lineWidth = 8; // pixels
Gdx.gl10.glLineWidth(lineWidth / camera.zoom);

现在,我得到的范围更广.但是,当屏幕电源关闭然后再打开时,就出现了问题,这条线又恢复了正常状态.如何保持宽度恒定?

Now, I get a wider line. But the problem arises when the screen power goes off and then turns on, the line becomes the normal one again. How to keep the width constant?

推荐答案

ShapeRenderer 具有用于绘制粗线的方法 rectLine .它绘制了一个旋转的填充矩形,其相对较小的一侧以传递给它的点为中心(作为坐标或作为 Vector2 对象).该方法具有参数 width 来设置线宽.

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.

您可以查看文档示例:

shapeRenderer.rectLine(new Vector2(x1,y1),new Vector2(x2,y2),lineWidth);

这篇关于在LibGDX中增加使用Shape Renderer绘制的线条的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆