I'm sorry i've been asking too many questions. Um can someone tell me how to make actors appear randomly? and in different places? thank you
// place outside all methods
private int timer = Greenfoot.getRandomNumber(100) + 100; // the amount of time before the actor appears
// in act
timer--;
if (timer == 0)
{
addObject(new ClassName(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()));
// I didn't see you say that a random amount should appear so there will just be one
timer = Greenfoot.getRandomNumber(100) + 100;
}{
/**
* Act - do whatever the A wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
//This is too make our image (balloons) smaller
GreenfootImage image = getImage();
image.scale(330,150);
setImage(image);
//This is too make the object fall
setLocation (getX(), getY()+7);
Greenfoot.setSpeed(+20);
//This is to make the object disappear when a the said key is pressed
String key = "enter";
if (Greenfoot.isKeyDown("A"))
{
getWorld().removeObject(this);
}
private int timer = Greenfoot.getRandomNumber(100) + 100;
timer--;
if (timer = 0)
{
addObject(new C.java(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()));
timer = Greenfoot.getRandomNumber(100) + 100;
}
}
}