This site requires JavaScript, please enable it in your browser!
Greenfoot back
JayWood860
JayWood860 wrote ...

2012/3/11

Please Help (With Scoreboard)

1
2
danpost danpost

2012/3/11

#
As far as the terminal window, your error message started with java.lang.NullPointerException at Score.<init>(Score.java:20) which is telling by '(Score.java:20)', at line 20 in the Score class, there is not something (or rather nothing ) where you are trying to get something. In your case, line 20 was the line that deals with the Font, and is trying to getFont() on 'image'. But 'image' is not yet initialized (it is still null), until line 30 of your most recent code post.
JayWood860 JayWood860

2012/3/11

#
i see, so the null pointer exception is saying im trying to reference something i haven't yet declared, below it is the class where the error is, and in "class.java.int" int would be the line in the class?
danpost danpost

2012/3/11

#
You may want to slow it down as it will be increasing as fast as how many frames per second the scenario runs. If you wish to slow it down some, add a couple extra instance integer variables to the class
private int maxCountdown = 40; // adjust value as needed
private int countdown = maxCountdown;
and change your act() method to
public void act()
{
    countdown--;
    if (countdown == 0)
    {
        add(1);
        countdown = maxCountdown;    }
}
danpost danpost

2012/3/11

#
JayWood860 wrote...
i see, so the null pointer exception is saying im trying to reference something i haven't yet declared, below it is the class where the error is, and in "class.java.int" int would be the line in the class?
Exactly!
JayWood860 JayWood860

2012/3/11

#
this is exactly what i needed. i see how the add method increments in relation to countdown and maxCountdown. thanks again for all the help
danpost danpost

2012/3/11

#
No problem. Glad to be of some help. I do not usually mention this, but you might want to check out some of my scenarios. There are a couple that have re-usable classes in them (a Bar class with multiple uses, including a health bar, or progress bar; and a Menu/Sub-Menu class combo; also, there is a true-time timer).
danpost danpost

2012/3/11

#
Again, glad to be of assistance. Post again if you run across any other problems.
You need to login to post a reply.
1
2