I'm trying to make something like a slingshot using libGDX.
My code
if (Gdx.input.isTouched()) {
ShapeRenderer sr = new ShapeRenderer();
sr.setColor(Color.BLACK);
sr.setProjectionMatrix(camera.combined);
sr.begin(ShapeType.Line);
sr.line(player.getLeft().x, player.getLeft().y,
Global.game_touch_position.x, Global.game_touch_position.y);
sr.line(player.getRight().x, player.getRight().y,
Global.game_touch_position.x, Global.game_touch_position.y);
sr.end();
}
Doing this i will have the output
This looks awful, and if I debug on my android phone , the logcat is spammed by the message
02-17 18:55:27.371: D/dalvikvm(7440): GC_CONCURRENT freed 1884K, 40% free 8287K/13635K, paused 15ms+2ms, total 40ms
And lags, I have like 30 fps when i touch the screen , and 60 when i don't...
I also need to draw the line with a little bit of thickness, so when the line is bigger, i will have to make it thicker, to give a cool look.
Which is the best way to draw a simple line in libgdx ? If I won't find any answer probably i'm going to draw circles from a point of the line to the other..this would look ok , but won't look like a slingshot...
Any help?