So I'm new here and I want to know how to have an actor randomly spawn whenever another actor is killed, eaten, etc


1 2 3 4 5 6 | if (getObjects(OtherActor. class ).isEmpty() && Greenfoot.getRandomNumber( 150 ) == 0 ) { int x = Greenfoot.getRandomNumber(getWidth()); int y = Greenfoot.getRandomNumber(getHeight()); addObject( new OtherActor(), x, y); } |