hello i have vierkant when its clicked it dissapaers butt i want when it disapaers i want a new one to spawn at a random location this is the code i have.
if (Greenfoot.mouseClicked(this)) {
getWorld().removeObject(this);
}
hello i have vierkant when its clicked it dissapaers butt i want when it disapaers i want a new one to spawn at a random location this is the code i have.
<< Code Omitted >>
Best is probably just to setLocation the clicked instance to a random location instead of removing and replacing it.
if (Greenfoot.mouseClicked(this)) {
World world = getWorld();
int x = Greenfoot.getRandomNumber(world.getWidth());
int y = Greenfoot.getRandomNumber(world.getHeight());
setLocation(x, y);
}