It might be best for you to upload your scenario to see what kind of mess you have right now. I can let you know when I have it, so you can delete it back off the site, if you wish.
// add the following instance field
private boolean hasStarted;
// in the constructor (after the 'super' statement)
if (!hasStarted)
{
player = new Player();
scoreCounter = new ScoreCounter("Score:");
levelNumber = 0;
hasStarted = true;
}// change declarations to private Player player; private Counter scoreCounter; private int levelNumber;
// change declarations to public static Player player; public static Counter scoreCounter; public static int levelNumber;
// change declarations to public static Player player; public static Counter scoreCounter; public static int levelNumber;
public background()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(894, 456, 1);
addObject(Levels.getScoreCounter(), 765, 66);
addObject(Levels.getPlayer(),565, 246);
public class Level extends World
{
public static PlayerTG player;
public static Counter scoreCounter;
public static int levelNumber;
public boolean hasStarted;
public Levels(int wide, int high, int size)
{
super(wide, high, size);
if (!hasStarted)
{
player = new PlayerTG();
scoreCounter = new Counter();
levelNumber = 0;
hasStarted = true;
}
}
public static Counter getScoreCounter()
{
return scoreCounter;
}
public static PlayerTG getPlayer()
{
return player;
}
public static int getLevel()
{
return levelNumber;
}
public static void changeLevel(int difference)
{
levelNumber += difference;
switch (levelNumber)
{
case 0: Greenfoot.setWorld(new easyLevel()); break;
case 1: Greenfoot.setWorld(new hardLevel()); break;
}
}
}