5

I'm trying to draw a filled rectangle in Libgdx and according to the API this should work:

shapeRenderer.begin(ShapeRenderer.ShapeType.FilledRectangle);

But it gives me an error and tells me to change FilledRectangle to Filled, Pointor Line.

imports: import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

Any ideas on what is causing this?

Green_qaue
  • 1,893
  • 4
  • 24
  • 55

2 Answers2

7

If you read the documentation, you'll see that ShapeRenderer.ShapeType is an enum with the following values defined:

Filled 
Line 
Point 

So the error message you're receiving is accurate.

If you want to draw a filled rectangle, choose the Filled enum type, then use shape rederer to draw a rectangle:

 shapeRenderer.begin(ShapeType.Filled);
 shapeRenderer.identity();
 shapeRenderer.translate(20, 12, 2);
 shapeRenderer.rotate(0, 0, 1, 90);
 shapeRenderer.rect(-width / 2, -height / 2, width, height);
 shapeRenderer.end();
House
  • 73,224
  • 17
  • 184
  • 273
2

With LibGdx 0.9.8 they removed ShapeyType.Rectangle, ShapeType.FilledRectangle and introduced Filled, Line, Point to optimize the shape rendering.

MartinTeeVarga
  • 2,839
  • 20
  • 48
Kumar Saurabh
  • 236
  • 2
  • 7