I have these two methods which should add and delete after some time a text.The problem is that I want to add text based on the user clicks but if he click again before the previous text was deleted the new text will be added over the old text.
void addText(String _text) { if(text.getWorld() != null) // i tried this if but it doesn't work { text.getWorld().removeObject(text); } text = new Label(_text, 30); getWorld().addObject(text, Dungeon1.WIDTH/2, 60); textOnScreen = true; textTimer.mark(); } void removeText() { if(textOnScreen && textTimer.millisElapsed() > 1500) { getWorld().removeObject(text); textOnScreen = false; } }