Heya,
I'm having a little bit of a problem getting my score from the last game to print. Basically, I have an actor called 'Scoreboard' and when I load a world called MyWorld it prints the score up at the top (successfully). I have another world called GameOver which is switched to when Rocket.class hits Asteroid.class. I want to print the same score I got from the last game on GameOver, but when I try it just says the score is 0. Here's the code for the scoreboard that you may need:
Thanks,
OF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import greenfoot.*; import java.awt.Color; public class Scoreboard extends Actor { int score = 0 ; public Scoreboard() { updateBoard(); //Tells the board to update when called } private void updateBoard() { setImage( new GreenfootImage( "Orbs: " + score, 20 , Color.black, new Color( 0 , 0 , 0 , 0 ))); //Print text } public void add( int addVal) { score += addVal; updateBoard(); //Calculate the score } public int getScore() { return score; } } |