• Log in or sign up for an account here: https://www.sythe.org/login

Greenfoot delay help

MissingUserName

Newcomer
Joined
Jul 16, 2011
Sythe Gold
0
Messages
1
I have a question about greenfoot. It's a beginners program that is supposed to help you understand java better, I think some of you might be familiar with it.
Anyways I wanted to ask if there was a way to make delay option inbetween instructions.
I created a instruction where if one object see's the other it's supposed to create another version of it. The problem is it is supposed to create only one but it creates hundreds the second it comes into contact. Here is my code
/**
* This method duplicates the object when caught.
*/
public void duplicate()
{
if (canSee (Crab.class))
{
getWorld().addObject (new Crab(), Greenfoot.getRandomNUmber(600), Greenfoot.getRandomNumber(400));

}
}

anyone know how I can make it so it delays the program by a few seconds after creating one of the object.
Appreciate any help, Thanks
 
Runescape Gamblingrunescape gambling
Back
Top