Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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();
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.