user4789408
user4789408

Reputation: 1196

LibGDX shaperenderer wrong color

I am in trouble setting the color of my rect. The color of my rect is grey with 0.5f alpha or black with 0. How could I set my color?

This is the code :

Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);


shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);

shapeRenderer.setColor(67 ,   34 , 167, 0.5f);

shapeRenderer.rect(0, 0, Width, Height);

shapeRenderer.end();

Upvotes: 1

Views: 1484

Answers (1)

Fish
Fish

Reputation: 1697

@Xoppa is right

the r, g, b and a in shapeRenderer.setColor(r, g, b, a); are always supposed to be between 0 and 1.

In your case it would be shapeRenderer.setColor(67/255f, 34/255f, 167/255f, 0.5f); And don't forget to add the f behind the numbers because we need float not double.

Upvotes: 3

Related Questions