0
\$\begingroup\$

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.setProjectionMatrix(cam.combined);
    shapeRenderer.setColor(1, 1, 0, 1);
    shapeRenderer.begin(ShapeType.Line);
    for (RectangleMapObject o : MovementSystem.objects.getByType(RectangleMapObject.class)) {
        Rectangle rect = o.getRectangle();
        shapeRenderer.rect(rect.x, rect.y, rect.height, rect.width);
    }

    shapeRenderer.end();

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!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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

\$\endgroup\$
3
  • \$\begingroup\$ hm yea that should work but why does it draw the rectangle rotated anyway? :/ Anyway thanks for the answer :) \$\endgroup\$
    – TreesAreOP
    Aug 5, 2014 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, 2014 at 15:02
  • \$\begingroup\$ okay, didn't see that sorry xD \$\endgroup\$
    – TreesAreOP
    Aug 5, 2014 at 15:04

You must log in to answer this question.

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