Hi!
In my game there is an Actor called Schneg who escapes before an other Actor called Achtung.
You need to survive 20 seconds and you win the game. If the Schneg hit the Achtung, you will lose the game and I want the clock to stop if you lose, but it does not work!
Here is my code of the Achtung:
and a part of the code of the clock:
I hope you can help me!
Thank you,
Fifilein
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class Achtung here.
*
* @author (Fifilein)
*
* @version (1.4)
*/
public class Achtung extends Quatrel
{
int horizontalSpeed = Greenfoot.getRandomNumber(1)-1;
int verticalSpeed = Greenfoot.getRandomNumber(1)-1;
/**
* Act - do whatever the Bananas wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(horizontalSpeed, verticalSpeed);
wrapAtEdge();
Actor getSchneg = getOneIntersectingObject (Schneg.class);
if (getSchneg != null)
{
World myWorld = getWorld();
myWorld.removeObject(getSchneg);
GameOver gameover = new GameOver();
myWorld.addObject(gameover, myWorld.getWidth()/2, myWorld.getHeight()/2);
TryAgain tryagain = new TryAgain();
myWorld.addObject(tryagain, 300, 300);
stopClock();
}
Actor Achtung = getOneIntersectingObject (Achtung.class);
if (Achtung != null)
{
World myWorld = getWorld();
myWorld.removeObject(this);
}
}
}
/**
* Pause the clock.
*/
public void stopClock() {
timeSaved = System.currentTimeMillis() - lastCurrentSecond;
count = false;
}

