How can I initialise an object from an ArrayList, when the program has been running for x amount of time?
in
Programming Questions
•
1 year ago
Hello,
I'm trying to implement a levelling system in my program. I have an object that is initialised at the beginning of the program, in setup, and halfway through (random time length really) I want to initialise another copy of that object class.
I tried doing it in draw, because it was only if a condition was met that it would initialise. But as you can imagine it kept drawing it, so that I had more of the object than I wanted.
Is there something I'm missing?
I did try something like this:
boolean conditionMet = false;
void setup() {
myObject = new myObject(10);
if(conditionMet) {
println("working");
myObject = new myObject(20);
}
}
void draw() {
myObject.draw();
myObject.move();
if(mills() > 10000) {
conditionMet = true;
}
}
But the object just would not initialise again!
Oh! I forgot to mention, my object class is an ArrayList too :)
Any help is much appreciated!
1