Hello, I am trying to make it so in my game when you kill the object that it spawns another one. I have looked up some stuff on how to do it, but I can't seem to get it to work. So, I was hoping some one could help. I do have some code done, but it isn't right. All of this is under my World class by the way.
Thank you!
public PizzaWorld()
{
super(SIZE, SIZE, 1);
setup2();
addFly();
addBee();
} public void addBee()
{
int spawnX = 0;
int spawnY = 0;
if (Greenfoot.getRandomNumber(2) == 0)
{
spawnY = Greenfoot.getRandomNumber(2) * (getHeight() - 1);
spawnX = Greenfoot.getRandomNumber(getWidth());
}
else
{
spawnY = Greenfoot.getRandomNumber(2) * (getWidth() - 1);
spawnX = Greenfoot.getRandomNumber(getHeight());
}
addObject(new bee(), spawnX, spawnY);
}

