Hello guys,
I am currrently programming a game for school where the player can move pacman and has to dodge the lobsters. A am trying to access the "stopThatSound" method from the Lobster so the sound stops when Pacman is killed, but it says "not a statement" (at the dot betweeen pacman and stopThatSound) when I try to access the method from the Lobster class. Can someone help me pls? (Sorry for my bad English, I am from Germany.)
This is my Lobster class.
This is the World class' code:
What did I do wrong?
public class Lobster extends Animal
{
public void act()
{
turnAtEdge();
randomTurn();
move();
lookForCrab();
}
public void turnAtEdge()
{
if ( atWorldEdge() )
{
turn(17);
}
}
public void randomTurn()
{
if (Greenfoot.getRandomNumber(100) > 90) {
turn(Greenfoot.getRandomNumber(90)-45);
}
}
/**
* Versucht eine Krabbe zu fangen; d.h. prüft, ob wir auf eine Krabbe gestoßen sind.
* Wenn ja, wird die Krabbe aus dem Spiel entfernt und die Ausführung des Programms beendet.
*/
public void lookForCrab()
{
if ( canSee(Pacman.class) )
{
eat(Pacman.class);
Pacmansworld pacmansworld = getWorld();
Pacman pacman = pacmansworld.getPacman();
pacman.stopThatSound;
}
}
}public class PacmansWorld extends World
{
private Pacman thePacman;
/**
* Constructor for objects of class PacmansWorld.
*
*/
public PacmansWorld()
{
super(1000, 1000, 1);
thePacman = new Pacman();
addObject(thePacman, 5, 5);
}
public Pacman getPacman()
{
return thePacman;
}
}

