Object Arrays and Accessing Variables
in
Programming Questions
•
1 year ago
Hello, I am trying to change an object's variable when the mouse is pressed but I must be doing something wrong. The error I get: The type of the expression must be an array type but it resolved to sketch_###.Drop
(drops[] was previously initialized and working properly with the rest of my program)
- void mousePressed(Drop drops) {
- for(int i = 0; i < counter; i++) {
- if(dist(mouseX,mouseY,drops[i].x,drops[i].y) < 20)
- drops[i].speedX += 1;
- }
- }
I can get rid of the error by using...
- void mousePressed(Drop drops[]) {
- //....//
- println("test");
- }
But then mousePressed is unresponsive because "test" will not print.
1