title: LibGdX Tiled Map Box2d collision with Polygon Map Object
body: <p>Im trying to create a small Side scroller for Android with LibGdx Tiled and Box2D.
  I'm using Object Layer to get the collision between Player and the World.
  This is working fine if i use Rectangles for the Object Layers.
  But when I'm trying to use Polygones the collision isn't working.
  What am I doing wrong.
  (Sry for spelling mistakes)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>for(MapObject object : map.getLayers().get(5).getObjects()){
              if(object instanceof RectangleMapObject) {
                  Rectangle rect = ((RectangleMapObject) object).getRectangle();
  
              bdef.type = BodyDef.BodyType.StaticBody;
              bdef.position.set((rect.getX() + rect.getWidth() / 2) / AoF.PPM, (rect.getY() + rect.getHeight() / 2) / AoF.PPM);
  
              body = world.createBody(bdef);
  
              shape.setAsBox(rect.getWidth() / 2 / AoF.PPM, rect.getHeight() / 2 / AoF.PPM);
              fdef.shape = shape;
              body.createFixture(fdef);
          }
          if(object instanceof PolygonMapObject){
             float[] vertices = ((PolygonMapObject) object).getPolygon().getTransformedVertices();
              float[] worldVertices = new float[vertices.length];
  
              for (int i = 0; i &lt; vertices.length; ++i) {
                  worldVertices[i] = vertices[i] / AoF.PPM;
              }
  
              shape.set(worldVertices);
              bdef.type = BodyDef.BodyType.StaticBody;
  
              body = world.createBody(bdef);
              fdef.shape = shape;
              body.createFixture(fdef);
          }
  </code></pre>