Shooting Game: Heads-up Display

I am trying to create a shooting game, and I want to display the “time played”, “number of bullets fired”, “Accuracy”, and “number of targets destroyed.” I am using a simple Gui to accomplish these. I am also using a crossHairs mark to help the player with aiming. However, if I display the crossHairs on the screen the other values disappear(time played,number of bullets fired, accuracy, and number of targets destroyed). If I remove the crossHairs mark, then the other values appear. So, what can I do in order to show the values on the screen and the crossHairs at the same time?

Show us the code how you create those components.

1 Like

Here is the code that I used to create the components

/*Declare variables shown on HUD @ class level/

private int timePlay = 120;//120 seconds or 2 minutes

private int bulletsFired = 0;

private double accuracy = 0;

private int targetsDestroyed = 0;

private BitmapText hud;

public void simpleInitApp(){

/*Heads-up Display/


guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

hud = new BitmapText(guiFont, false);


hud.setText("Time_Play: "+timePlay + “t”+

"Bullets_Fired: "+ “t” +bulletsFired+ “Accuracy: " + accuracy +

“t”+ “Targets_Distroyed: " + targetsDestroyed);

hud.setLocalTranslation(180, hud.getLineHeight(),0);




protected void initCrossHairs(){


guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

BitmapText ch = new BitmapText(guiFont, false);

ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);

ch.setText(”+”); // fake crosshairs :slight_smile:

ch.setLocalTranslation( // center

settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,

settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);



[java]protected void initCrossHairs(){


you remove it… so it disappear … you should only remove children you need to remove.

1 Like

yes, you are right. Now it works thanks a lot oxplay2