I have two Vectors which indicate the ending points of each line. I am trying to draw similar lines to football formation lines like these:
My main problem using ShapeRenderer is:
- ShapeRenderer coordinates are relative to screen coordinates and not Scene/Table/Stack. This creates varying coordinate points in different screen sizes. Although I can fix it, I still experience get varying line width in different screen sizes.
- ShapeRenderer performance issues as it is mainly intended for debugging.
- ShapeRenderer draws over all Actors.
I have tried drawing the lines as a Pixmap and adding them to the scene as an image. This is part of the constructor to my custom class which extends Group.
pixmap = new Pixmap( 16, 16, Pixmap.Format.RGBA8888 ); pixmap.setColor(Color.RED); pixmap.drawLine(Ax, Ay, Bx, By); Texture pixmaptex = new Texture(pixmap, Pixmap.Format.RGB888, false); Image pixmapimg = new Image(pixmaptex); pixmapimg.setPosition(x, y); this.addActor(new Image(pixmaptex)); pixmap.dispose();
I am trying to draw using this but it just draws a square with the pixmap width and height at (0,0) of the stack. Which is the best class to extend to draw this lines? I am expecting to write a custom class if this doesn't work.