Hello! I have bought the Greenfoot book and I'm already at Chapter 9.10. There, I'm at exercise 9.69, which is a final excersise. I'm trying to add some score to my Asteroids game. When I'm trying to call the add(score) method (which belongs to the Counter class) from the World (Space), I get this error: non-static method cannot be referenced from a static context. I don't quite understand how to fix it, and there isn't a 'solution' in the book. (It's the final exercise).
Here is some of the code:
Counter class:
Space class:
Calling the countScore(score) method from the Asteroid class:
I hope I got the formatting right as this is my first post.
Thank you!
/**
* Add a new score to the current counter value. This will animate
* the counter over consecutive frames until it reaches the new value.
*/
public void add(int score) //This is the add(score) class from the method Counter. It adds
{ //the score if you type it in the parameter section.
target += score;
} public void countScore(int score)//This method belongs to the world. When you
/** //add the score here, it automatically should get added to the Counter class.
* Count the score.
*/
{
Counter.add(score); //Here is where I get my error. I don't understand why.
}Space space = (Space) getWorld();//Here it's supposed to add 20 points to the score whenever a bullet touches an asteroid. I don't have any errors here. space.countScore(20);

