Im modifying the little crab scenario for my school's comp sci class. On my 3rd level i want it to play certain sounds and music at certain points when conditions are met in the world. When i get to that level it won't work. Help. Code for lvl not working is pasted.
import greenfoot.*;
// (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Digdug here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Digdug extends World
{
/*
* DD = Intro
* DDOM= One left
* DDEOG = End
* DDW = Win
*/
private GreenfootSound DD;
private GreenfootSound DDOM;
private GreenfootSound DDEOG;
private GreenfootSound DDW;
public void sounds()
{
GreenfootSound DD = new GreenfootSound ("DD.wav");
GreenfootSound DDOM = new GreenfootSound ("DD_OneMore.wav");
GreenfootSound DDEOG = new GreenfootSound ("DD_EOG.wav");
GreenfootSound DDW = new GreenfootSound ("DD_Win.wav");
DD.play();
}
public void LvlChange()
{
int actors = numberOfObjects();
if(actors == 3)
{
DD.stop();
DDOM.play();
}
if(actors == 2)
{
DDOM.stop();
DDW.play();
Greenfoot.setWorld(new Pacman());
}
}
/**
* Constructor for objects of class Pacman.
*
*/
public Digdug()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1150, 600, 1);
addObject(new Digdugman(),Greenfoot.getRandomNumber(1150),Greenfoot.getRandomNumber(600));
addObject(new Frygar(),Greenfoot.getRandomNumber(1150),Greenfoot.getRandomNumber(600));
populate();
}
public void populate()
{
for(int i=0;i < 2; i++)
{
addObject(new Digdugmon(),Greenfoot.getRandomNumber(1150),Greenfoot.getRandomNumber(600));
}
}
public void act()
{
LvlChange();
}
}


