i understand :) just a moment ill remove all the sound now.
static int score = 0;
static {
score = 0;
} Counter counter = new Counter();
addObject(counter, 462, 575);
counter.setLocation(454, 568);public GameOver(Counter counter)
public GameOver()
Greenfoot.setWorld(new GameOver()); as opposed to: [code]Greenfoot.setWorld(new GameOver(counter));
import greenfoot.*;
import java.awt.Color;
public class GameOver extends World
{
static GreenfootSound laugh = new GreenfootSound("gameOverLaugh.mp3");
Counter counter = null;
public GameOver(Counter counter)
{
super(800, 600, 1);
this.counter = counter;
prepare();
}
public void act()
{
if( !laugh.isPlaying())
{
laugh.setVolume(50);
laugh.playLoop();
}
}
private void prepare()
{
TryAgain tryagain = new TryAgain();
addObject(tryagain, 681, 551);
laughingSkull laughingskull = new laughingSkull();
addObject(laughingskull, 683, 119);
addObject(counter, 462, 575);
counter.setLocation(454, 568);
}
}Background bg = new Background();
bg.setCounter(counter);
Greenfoot.setWorld(new Background());
// the setCounter method in Background
public void setCounter(Counter counter)
{
this.counter = counter;
addObject(counter, x, y);
}public class Background extends World
{
static GreenfootSound music;
static
{
music = new GreenfootSound("inGameMusic.mp3");
music.setVolume(50);
}
Counter counter;
public Background()
{
this(new Counter());
Start.title.stop();
}
public Background(Counter counter)
{
super(800, 600, 1);
this.counter = counter;
prepare();
}
private void prepare()
{
addObject(counter, 335,11);
addObject(new Survivor(), 391, 323);
addObject(new Spawner(), 89, 311);
addObject(new scoreboard(), 715, 535);
}
public void act()
{
if(!music.isPlaying()) music.playLoop();
}
public Counter getCounter()
{
return counter;
}
}Greenfoot.setWorld(new Background(counter));
public void setCounter(Counter counter)
{
this.counter = counter;
addObject(counter, x, y);
} Background bg = new Background();
in place of
[code] World world;
world = getWorld();
world.removeObject(this);
Greenfoot.setWorld(new Background());World world;
world = getWorld();
Background bg = new Background();
bg.setCounter(counter);
Greenfoot.setWorld(new Background());
world.removeObject(this);bg.setCounter(counter);
Greenfoot.setWorld(bg);
World world; world = getWorld(); GameOver go; go = (GameOver)world; Counter counter = go.getCounter();
Counter counter = ((GameOver)getWorld()).getCounter();