Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdxhttps://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope I helped!

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope I helped!

Copied from here: https://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope I helped!

edited body
Source Link

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope it helpsI helped!

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope it helps!

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope I helped!

Source Link

Copied from here: http://stackoverflow.com/questions/15733442/drawing-filled-polygon-with-libgdx

Basically, you define a PolygonSpriteBatch using a PolygonSprite and a PolygonRegion:

PolygonSprite poly;
PolygonSpriteBatch polyBatch;
Texture textureSolid;

You then create them like this, giving the region a texture and the 4 corners coordinates (for the texture, you can load a plain solid colored texture, gray or red in your case):

PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
  new float[] {
    x1, y1,
    x2, y2,
    x3, y3,
    x4, y4
});
poly = new PolygonSprite(polyReg);
poly.setOrigin(oX, oY);
polyBatch = new PolygonSpriteBatch();

And draw it like this:

polyBatch.begin();
poly.draw(polyBatch);
polyBatch.end();

Hope it helps!