Hello, I am attempting to create a game where objects (food specifically) are falling down from the top edge. Calling the addObject() method from the constructor will only create the objects once (from what I learned); however, I want to continually spawning objects from the top slowly as the game progresses. I have tried placing the code in the act() method, but the objects were spawning really fast like a thunderstorm, which was not my intention. So far, I have a spawnFood() method to spawn the food, and it is placed inside the act() method.
By the way, if I need further help for this game, should I expand this discussion even if the coding topic is different, or should I make another discussion?
if(Greenfoot.getRandomNumber(15) < 6)
{
addObject(new Food1(), Greenfoot.getRandomNumber(1000), 2);
}
if(Greenfoot.getRandomNumber(15) < 6)
{
addObject(new Food(), Greenfoot.getRandomNumber(1000), 2);
}
//and so forth
