how to draw a rectangle in libgdx

Solutions on MaxInterview for how to draw a rectangle in libgdx by the best coders in the world

showing results for - "how to draw a rectangle in libgdx"
Ana Sofia
05 Nov 2020
1private ShapeRenderer shapeRenderer;
2
3// in create method:
4shapeRenderer = new ShapeRenderer();
5shapeRenderer.setAutoShapeType(true);
6
7// in render method:
8shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
9shapeRenderer.setColor(Color.GREEN);
10shapeRenderer.rect(x, y, width, height);
11shapeRenderer.end();