i have a fish object that i want to remove and then add a new fish object when i clik the object whit the mouse i have tryed different ways but cant work it out so ill be glad if someone culd help me out :-)
//in your fish class; public void act() { if (Greenfoot.mouseClicked(this)) { getWorld().addObject(new Fish(), Greenfoot.getRandomNumber(getWorld().getWidth()), Greenfoot.getRandomNumber(getWorld().getHeight()));//add a new fish at a random position; getWorld().removeObject(this); return; } }
getWorld().addObject(new Fish(), Greenfoot.getRandomNumber(500)<10), Greenfoot.getRandomNumber(400)<10);
int x = Greenfoot.getRandomNumber(480)+10;