I have basically made my game change levels when the score counter gets to 12, however when the world changes, the score counter resets and i need a way to keep the Score the same when the world changes.import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Counter here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Counter extends Actor
{
private int score = 0;
/**
* Act - do whatever the Counter wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
public Counter()
{
setImage( new GreenfootImage("Score:" + score, 25, java.awt.Color.WHITE, java.awt.Color.BLACK));
}
public void changeScore(int number)
{
score = score + number;
setImage(new GreenfootImage("Score: "+ score, 25, java.awt.Color.WHITE, java.awt.Color.BLACK));
if(score == 12)
{
Greenfoot.setWorld(new level2());
}
}
}

