Hi!
So I have experimented with timers before (on a basic level), but never got anything elegant. Actually I think my approach is pretty messy. I’m working on a small game at the moment, and want to add more objects to an ArrayList over time. This is how I did it:
void draw(){ // simplification
void addNewTargetObjects(){
if(timeSinceStart() >= 5000)
targetList.add(new Target());
}
}
timeSinceStart() is:
float timeSinceStart(){
float timeSinceStart = dist(millis(), 0, startTime, 0);
return timeSinceStart; // float startTime = time the game was started/reset
}
But this means that another object is being added every single frame. That’s a liiiiittle bit to much. I would solve this problem by creating a boolean that stores whether the object was already added or not, but that creates just so many unnecessary variables/aka a big array. I just don’t like that method. Do you have any ideas?