I'm trying to create a HUD that basically displays 'debugging' information. One of these is the location of a the camera. Whenever there's a change in cam.getLocation(), I would call an updateHUD. Snippet of this is below:
String s8 = "Cam Coordinate: (" + cam_location.getX() + ", " + cam_location.getY() + ", " + cam_location.getZ() + ")";
fpsNode.detachChild(t8);
t8 = new Text("t8", s8);
Text[] myText = { t8 };
int delta = 0;
for(Text t:myText) {
t.setTextColor(ColorRGBA.green);
t.setLocalTranslation(new Vector3f((display.getWidth() /
2f - 8f) + -270, (display.getHeight() / 2f - 8f) + 240 - delta, 0));
fpsNode.attachChild(t);
delta += 20;
}
As you can image having this line of code run hundreds of times a second can be resource extensive due to the strings being immutable. Is there a cleaner way of doing this? Attaching and detaching just doesn't seem like a good idea.