I'm having a weird problem with the LibGDX ShapeRenderer where it draws everything rotated. Here are some images to show you what i mean:

This is what it looks like in Tiled(Map Editor): Tiled view

This is how it looks like in game:

ingame render

As you can see, its rotated.

Heres the Code i use to render the mapobjects:

    shapeRenderer.setColor(1, 1, 0, 1);
    for (RectangleMapObject o : MovementSystem.objects.getByType(RectangleMapObject.class)) {
        Rectangle rect = o.getRectangle();
        shapeRenderer.rect(rect.x, rect.y, rect.height, rect.width);


The rectangle is positioned at the right place and it is definitely NOT rotated! I checked this with a small collision detection test where i moved another rectangle over this one. So it just gets drawn like this and i have no idea why^^ Would be nice if anybody could help me :)

Thanks for your help in advance!


Swapping the width and height in ShapeRenderer.rect should fix the problem, see the documentation.

|improve this answer|||||
  • \$\begingroup\$ hm yea that should work but why does it draw the rectangle rotated anyway? :/ Anyway thanks for the answer :) \$\endgroup\$ – TreesAreOP Aug 5 '14 at 14:59
  • \$\begingroup\$ rect expects first the width, then the height of the rectangle. You pass them the other way around. Is that intentional? \$\endgroup\$ – Raginmari Aug 5 '14 at 15:02
  • \$\begingroup\$ okay, didn't see that sorry xD \$\endgroup\$ – TreesAreOP Aug 5 '14 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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