BitmapText

hello…



how can I removed the text that printed in the screen first and print the next…



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

final BitmapText timeText = new BitmapText(guiFont, false);

timeText.setSize(guiFont.getCharSet().getRenderedSize());



guiNode.attachChild(timeText);

timeText.setText("Time: " + secs);

wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);



this code was print:



Time: 1 (for example)

and the next is Time: 2

but the problem is (Time: 1 does not remove in the screen Time: 2 prints over the printed Time: 1)

how can I clear the screen or remove the first printed andd prints the next one…



Thanks for help…

is all of that in an update loop or something? looks like you keep creating multiple bitmapTexts, just create 1, and use setText on it, and it should work fine.

thanks… uhm 1 question,

I created countdown timer, that is the reason I put the bitmapText in update loop.

its something like this:



@Override

public void simpleUpdate(float tpf) {

updateTime();

}



private void updateTime(){

milisecs++;

boolean print = false;

if(milisecs == 100){

milisecs=0;

secs++;

print = true;

}



if(secs == 60){

secs=0;

mins++;

print = true;

}



if(print == true){



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

final BitmapText wayPointsText = new BitmapText(guiFont, false);

wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());



guiNode.attachChild(wayPointsText);



wayPointsText.setText("Time: " + secs);



wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);



print =false;

}



}



–how can I solution this to avoid the problem aforementioned?

put this in the constructor or something:



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

wayPointsText = new BitmapText(guiFont, false);

wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());

guiNode.attachChild(wayPointsText);

[/java]



and this in the “print == true”, which btw you can just write if(print)

[java]wayPointsText.setText(“Time: ” + secs);

wayPointsText.setLocalTranslation((cam.getWidth() – wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);[/java]

Yeah! That’s really work… Thanks a lot…



I follow that uhm the only thing that is not there is to globalize the BitmapText variable…



Thank you again!!!

:wink: