I'm making a typing game and am trying to call the method to add 1 to my score from the world.
The code errors whenever I try to call the method though. Can anyone help me fix this.
World class
Score class
if (Greenfoot.isKeyDown("enter"))
{
if (Typed == WordBank1.word)
{
Score.addScore();
}
else
{
Lives.minusLives();
}public class Score extends Actor
{
public static int score = 0;
public static GreenfootImage image;
public Score()
{
image = new GreenfootImage(160, 50);
image.setColor(Color.RED);
image.setFont(new Font("Calibri", Font.BOLD, 18));
printScore();
}
public void addScore()
{
score = score + 1;
printScore();
}
public int getScore()
{
return score;
}
public void NextL()
{
if (score == 30)
{
Greenfoot.setWorld(new Forest());
}
if (score == 70)
{
Greenfoot.setWorld(new Castle());
}
if (score == 120)
{
Greenfoot.setWorld(new GameWin());
}
}
public void printScore()
{
image.clear();
image.drawString("Score: "+score, 10, 25);
setImage(image);
}
}
