I have a score variable in my GameWorld which works, but I need it to also be accessed by the EndWorld which should show the final score.
What can I do to my EndWorld to have it access that final score? I need to display is as text. Also would it be possible to have my actors access the score value while its increasing? Please help.
public class GameWorld extends World { public int score = 0; public GameWorld() { super(600, 400, 1); setBackground("sandstone.jpg"); thing t1 = new thing(); frog f1 = new frog(); spider s1 = new spider(); addObject(t1, 80, 80); int y = Greenfoot.getRandomNumber(getHeight()); int ys = Greenfoot.getRandomNumber(getHeight()); addObject(f1, 610, y); addObject(s1, 610, ys); showScore(); score++; } public void act(){ count(); } public void count(){ score = score + 1; showScore(); } public void showScore() { showText("Score: " + score, 50, 25); } }