Hello, I have some code here for my game. It spawns a random orb for random numbers. Sometimes it's great but sometimes it spawns multiple which are un-dodgable. Is there a way to make this code check if an orb is in the world already and if so don't spawn?
public void randomSpawn() {
if (Greenfoot.getRandomNumber(80) > 78)
{
Orb orb = new Orb();
addObject(orb,526,513);
}
}
public void waitForSpawning() {
if(waitTime > 1500)
{
randomSpawn();
waitTime = 0;//resets timer
}
waitTime ++;//timer counts up
}
