Hello,
I have a monster class. In it are Monster-Blue and Monster-Yellow. I want to spawn a monster from it.
I would say to Java: "Spawn me an object of the superclass Monster"
How have I to program it?
getWorld().addObject(new Monster(), x, y);
int g = Greenfoot.getRandomNumber(20);
if(g == 10)
{
getWorld().addObject(new Monster-Blue(), x, y);
}
if(g == 20)
{
getWorld().addObject(new Monster-Yellow(), x, y);
}int g = Greenfoot.getRandomNumber(20);
if(g == 10)
{
getWorld().addObject(new Monster-Blue(), x, y);
}
if(g == 20)
{
getWorld().addObject(new Monster-Yellow(), x, y);
}