Is it possible to change the font size of showText(java.lang.String text, int x,int y) in the world class, or do i have to replace it with an actor showing text?


1 | public class SimpleActor extends greenfoot.Actor {} |
1 2 3 4 5 6 7 8 9 10 11 12 13 | // with an instance reference field to the actor private Actor message = new SimpleActor(); // and with a method to update it image public void setMessage(String text) { GreenfootImage image = null ; if (text != null && ! "" .equals(text)) image = new GreenfootImage(text, 28 , null , null ); message.setImage(image); } // with something like this line in constructor addObject(message, 100 , 20 ); |
1 2 3 4 5 6 7 | // in class to set a message setMessage( "Hello, world!" ); // in class to clear a message setMessage( null ); // or 'setMessage("");' // from Actor object in a world called MyWorld ((MyWorld)getWorld()).setMessage( "Hola, mundo!" ); |