I'm using LibGDX and the SpriteBatch and ShapeRenderer are having a perspective problem or something... When I draw something with both (code below), the planet texture is smaller than it should be. I can even manually set the size values and it's still wrong.

I'm setting:

    Matrix4 matrix = cam.combined;

and the draw code is...

            // outline

            // planet tex
            batch.draw(c.getTexture(), c.getDrawPosition().x, c.getDrawPosition().y, c.getSize(), c.getSize());
            batch.draw(c.getShadow(), c.getDrawPosition().x, c.getDrawPosition().y, c.getSize(), c.getSize());

Both the texture and the shape are centered properly and c.getSize() should always be returning the same value, so I'm trying to figure out why this isn't working. I've tried manually setting the value for size and it still does it, so either the texture is being rendered at the wrong size or somehow the ShapeRenderer and SpriteBatch are using a different camera/projection.


1 Answer 1


It looks like you want to draw the circle with half the c.size () as the circle method's third parameter is radius, not diameter.

sr.circle(c.getPos().x,c.getPos().y,c.getSize() / 2.0f);

Either that or multiply the width and height passed in the draw calls for the textures by two.

The draw calls on the SpriteBatch takes width and height and the width of a circle is two times the radius.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .