Search code examples
libgdxpolygonshape-rendering

Polygon shape rendering in LibGdx


I created a rectangle polygon like this:

polyrect=new Polygon(new float[]{0,0,width,0,width,height,0,height});
polyrect.setOrigin(width,0);
polyrect.setRotation(45f);
polyrect.setPosition(getX(),getY());
shapeRenderer.polygon(polySwatter.getTransformedVertices());

It worked well but now I want to draw an inverted triangle like this.

enter image description here

How can I draw an inverted triangle by this method?


Solution

  • You can set vertices in this way, that gives you inverted triangle.

    polyrect=new Polygon(new float[]{width/2f,0,width,height,0,height});
    polyrect.setOrigin(width,0);
    //polyrect.setRotation(45f);
    polyrect.setPosition(200,200);