I have created a text class where I use the method in it to display text messages on the screen after validating certain conditions. I want the text to disappear from the screen after a few seconds so that I can continue with the remaining functionality.
I have the following code for Text class
And this is one instance where I use the Text class
I want this message to disappear. How do I do it?
public class Text extends Actor { public Text() { this(""); } public Text(String text) { setText(text); } public void setText(String text) { setImage(new GreenfootImage(text, 24, Color.black, new Color(0, 0, 0, 0))); } }
if(name.equals("Penny")) { Text errormsg=new Text(); getWorld().addObject(errormsg, 600, 220); errormsg.setText("You cannot take coke with a penny"); Greenfoot.stop(); }