Here’s an example which displays a blue background() for 5 seconds, followed by a red background() for 2 seconds, relying on a class library I coded called “Countdown.java”:
/**
* Countdown Pause/Resume Example (v1.0)
* GoToLoop (2018/Jun/04)
*
* https://Discourse.Processing.org/t/
* array-and-object-moving-and-not-moving-coding-questions/698/2
*/
import gotoloop.countdown.Countdown;
final Countdown countdown = new Countdown();
boolean paused = true;
void draw() {
managePause();
background(paused? #FF0000 : #0000FF);
}
void managePause() {
if (countdown.done) {
countdown.delay = (paused ^= true)? 2000 : 5000;
countdown.start();
println("Paused:", paused, "\tAwaiting",
countdown.delay/1000, "seconds...");
}
}