newbie mouseReleased() order?
in
Programming Questions
•
5 months ago
hi
I am just starting with processing & programming
Why do I get an error when I write my mouseReleased() function after draw() and no error if I write it before? while in the simple program code#2 (with no for loop), there is no error with mouseRelease() placed after draw()
thanks!
No error with mouseRelease() placed after draw()
I am just starting with processing & programming
Why do I get an error when I write my mouseReleased() function after draw() and no error if I write it before? while in the simple program code#2 (with no for loop), there is no error with mouseRelease() placed after draw()
thanks!
- int x1;
int y1;
void setup() {
size(400, 400);
}
void mouseReleased () {
println("x:" + mouseX + ", y:" + mouseY);
}
void draw() {
x1 = 0;
y1 = 0;
background(255);
for (int i = 0; i < 5; i++) {
line(x1, y1, mouseX, mouseY);
x1+=100;
}
//error if placed here
}
No error with mouseRelease() placed after draw()
- void setup () {
size (400, 400);
}
void draw () {
background (255);
line (mouseX, mouseY, 0, 0);
line (mouseX, mouseY, 100, 0);
line (mouseX, mouseY, 200, 0);
line (mouseX, mouseY, 300, 0);
line (mouseX, mouseY, 400, 0);
}
void mouseReleased () {
println("x:" + mouseX + ", y:" + mouseY);
}
2