I am trying to put a delay on the time you can shoot a bullet but I don't know how.
Can someone please incorporate the delay into my code?
Thanks a lot!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Ship here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Ship extends Actor
{
/**
* Act - do whatever the Ship wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.isKeyDown("right")){
setLocation(getX()+7, getY());
}
if(Greenfoot.isKeyDown("left")){
setLocation(getX()-7, getY());
}
if(Greenfoot.isKeyDown("up")){
setLocation(getX(), getY()-7);
}
if(Greenfoot.isKeyDown("down")){
setLocation(getX(), getY()+7);
}
if(Greenfoot.isKeyDown("space")){
getWorld().addObject (new bullet (), getX()+0, getY()-2);
}
}
}

