When I run your code, I get an error on this line:
ellipse(Dot.BallX, Dot.BallY, Dot.BallS, Dot.BallS);
The variable "Dot" does not exist
That error message tells me that the code tries to use a variable named Dot
, but no variable with that name was ever created.
So I look at the surrounding code:
void draw() {
for (int i = 0; i<= Koala.size(); i++) {
Koala.get(i);
ellipse(Dot.BallX, Dot.BallY, Dot.BallS, Dot.BallS);
}
}
And indeed, I don’t see a Dot
variable that was created in this scope (either inside this function or at the top of the sketch).
I’m guessing that you meant to get the Ball
instance out of your ArrayList
like this:
void draw() {
for (int i = 0; i<= Koala.size(); i++) {
Ball Dot = Koala.get(i);
ellipse(Dot.BallX, Dot.BallY, Dot.BallS, Dot.BallS);
}
}
After I do that, I get a different error:
Type mismatch: cannot convert from Object to Ball
This is because you need the <>
type (also called generics) in your ArrayList
definition:
ArrayList<Ball> Koala = new ArrayList(5);
And if I fix that, I get a different error, but it’s very similar to your first issue so I’m betting that you can fix that one yourself.
Try that out, and if you’re still banging your head against it after 15 minutes, let me know and I’ll try to walk you through it!
Thanks again for posting. I know that asking questions can be scary, but it’s the only way we learn!