How to pause? and resume by keypress?
in
Programming Questions
•
2 years ago
Inside draw(), with noLoop() in setup(), I am drawing many graphic in succession, each one erasing the previous one.
So I want to pause between them.
I could use delay(), but I want the user to have control by pressing any key (spacebar,...) to move on.
So I tried this, but it doesn't work properly:
void draw() {
background(0,0,0);
//...draw something
while (!keyPressed) {
}
background(0,0,0);
//...draw something
while (!keyPressed) {
}
background(0,0,0);
//...draw something
}
background(0,0,0);
//...draw something
while (!keyPressed) {
}
background(0,0,0);
//...draw something
while (!keyPressed) {
}
background(0,0,0);
//...draw something
}
One reason I have problem is
"Because the screen is updated only at the end of
draw(), the program appear to freeze",
as I just read in the Delay() reference page.
Baically all I want is this (in pseudo code):
void draw() {
show drawing_1, wait for keypress
show drawing_1, wait for keypress
show drawing_2, wait for keypress
show drawing_3, wait for keypress
}
1