Greenfoot delay help

Discussion in 'Programming General' started by MissingUserName, Jul 16, 2011.

Greenfoot delay help
  1. Unread #1 - Jul 16, 2011 at 1:26 PM
  2. MissingUserName
    Joined:
    Jul 16, 2011
    Posts:
    1
    Referrals:
    0
    Sythe Gold:
    0

    MissingUserName Newcomer

    Greenfoot delay help

    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
     
< Learning JavaScript | need help with basic, coding WILL PAY >

Users viewing this thread
1 guest


 
 
Adblock breaks this site