I've made a rudimentary Timer that's a subclass of Actor. I originally had the "showText" bit at the end of the updateTime() method, but since that didn't work I tried it in the Act method with the same result. The code works just fine if it's inside my World class, but it doesn't work inside the Timer one. What's the best way to get the text to display?
import greenfoot.*; /** * Write a description of class Timer here. * * @author (your name) * @version (a version number or a date) */ public class Timer extends Actor { int numOfActCycles; int minutes; int seconds; String timeText; /** * Act - do whatever the Timer wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { numOfActCycles--; updateTime(); getWorld().showText("Time: " + timeText, 55, 10); } /***************************************** * Updates and displays the time left in 0:00 format. */ public void updateTime() { if(numOfActCycles >= 3600 ) minutes = 1; else minutes = 0; if(numOfActCycles % 60 == 0) seconds -= 1; timeText = minutes +":" + seconds; if(seconds < 10) timeText = minutes + ":0" + seconds; if(seconds == -1) seconds = 59; } }