So my meteor gets destroyed when i hit it with my missile. How would i make it respawn every time the original one dies?
int x = Greenfoot.getRandomNumber(getWorld().getWidth()); // get a random x location int y = Greenfoot.getRandomNumber(getWorld().getHeight()); // get a random y location setLocation(x, y); // re-locate meteor
Meteor meteor=(Meteor) getOneIntersectingObject(Meteor.class); // get random x and y meteor.setLocation(x, y);
private void eatWorm()
{
Actor Worm;
Worm = getOneObjectAtOffset (0,0,Worm.class);
if(Worm != null)
{
Worm worm = getOneIntersectingObject (Worm.class);
int x = Greenfoot.getRandomNumber(getWorld().getWidth()); // get a random x location
int y = Greenfoot.getRandomNumber(getWorld().getHeight()); // get a random y location
setLocation(x, y); // re-locate meteor
counter.add(1);
Greenfoot.playSound ("eating.wav");private void eatWorm()
{
Actor worm;
worm = getOneObjectAtOffset (0,0,Worm.class);
if(worm != null)
{
int x = Greenfoot.getRandomNumber(getWorld().getWidth());
int y = Greenfoot.getRandomNumber(getWorld().getHeight());
worm.setLocation(x, y);
counter.add(1);
Greenfoot.playSound ("eating.wav");
}
}