Hi, everybody well I programed a game like space invaders but after I finished it I got the idea of adding a few new things and thats what I did. However now it shows a few different error messages, I got nobody to help me so I decided to post the first error message that appears on the screen when an enemy reaches the end of the world. Here are the lines:
public class EnemyRocket extends Animal
{
int changeSize = 1;
int LifeCounter = 3;
int counter = 0;
/**
* Act - do whatever the EnemyRocket wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setLocation(getX(),getY()+1);
if (counter >= 200)
{
setLocation(getX(), getY()+7);
}
if (counter >= 1000)
{
setLocation(getX(), getY()+12);
}
if (counter >= 20)
{
setLocation(getX(), getY()+4);
}
if (changeSize == 1)
{
GreenfootImage image = getImage();
image.scale(image.getWidth() - 50, image.getHeight() - 50);
setImage(image);
changeSize = 0;
}
if (canSee(MainRocket.class))
{
getWorld().removeObject(this);
}
if (atWorldEdge())
{
getWorld().removeObject(this);
getWorld().addObject(new EnemyRocket(), Greenfoot.getRandomNumber(800),Greenfoot.getRandomNumber(170) );
}
if (getWorld() == null)
{
return;
}
if (canSee(EnemyRocket.class))
{
getWorld().addObject(new EnemyRocket(), Greenfoot.getRandomNumber(800),Greenfoot.getRandomNumber(170) );
getWorld().removeObject(this);
}
counter++;
}
}
It always says that
getWorld().addObject(new EnemyRocket(), Greenfoot.getRandomNumber(800),Greenfoot.getRandomNumber(170) );
is an unknown error. Can you guys see a mistake here?
