NewbJava wrote...
error on line 44 saying "int cannot be dereferenced".
import greenfoot.*;
public class MyWorld extends World
{
static Actor scoreDisplay;
static Actor highScoreDisplay;
public static int score;
static int highScore;
public MyWorld()
{
super(600, 400, 1, false);
scoreDisplay = new SimpleActor();
highScoreDisplay = new SimpleActor();
score = -1;
highScore = -1;
adjustScore(1);
}
public MyWorld(int w, int h, int c)
{
super(w, h, c);
}
static void adjustScore(int amt)
{
score += amt;
GreenfootImage img = new GreenfootImage("Score: "+score, 24, Color.RED, new Color(0, 0, 0, 0));
scoreDisplay.setImage(img);
if (score > highScore)
{
highScore = score;
img = new GreenfootImage("High score: "+highScore, 24, Color.RED, new Color(0, 0, 0, 0));
highScoreDisplay.setImage(img);
}
}
public void act()
{
Greenfoot.setWorld(new MeteorsWorld());
}
}
public MyWorld(int w, int h, int c, boolean b)
{
super(w, h, c, b);
}import greenfoot.*;
public class MyWorld extends World
{
static Actor scoreDisplay;
static Actor highScoreDisplay;
public static int score;
static int highScore;
public MyWorld()
{
super(600, 400, 1);
scoreDisplay = new SimpleActor();
highScoreDisplay = new SimpleActor();
score = -1;
highScore = -1;
adjustScore(1);
}
public MyWorld(int w, int h, int c, boolean b)
{
super(w, h, c, b);
}
public MyWorld(int w, int h, int c)
{
super(w, h, c);
}
static void adjustScore(int amt)
{
score += amt;
GreenfootImage img = new GreenfootImage("Score: "+score, 24, Color.RED, new Color(0, 0, 0, 0));
scoreDisplay.setImage(img);
if (score > highScore)
{
highScore = score;
img = new GreenfootImage("High score: "+highScore, 24, Color.RED, new Color(0, 0, 0, 0));
highScoreDisplay.setImage(img);
}
}
public void act()
{
Greenfoot.setWorld(new MeteorsWorld());
}
}