Exit from a function
in
Programming Questions
•
9 months ago
Hi,
i'm building a kind of strobe light effect that last for some seconds.
It works but I cannot stop the function to work (timer keep working).
How should I use the return to exit from a function?
void strobe() {
int timer = millis()-start;
if (timer > 10000) {
drawNothing();
sendOSC(3);
println(timer);
timer = 0;
return;
}
if (timer % 2 == 0){
drawMoreRects();
} else {
drawWhiteRects();
}
}
i'm building a kind of strobe light effect that last for some seconds.
It works but I cannot stop the function to work (timer keep working).
How should I use the return to exit from a function?
void strobe() {
int timer = millis()-start;
if (timer > 10000) {
drawNothing();
sendOSC(3);
println(timer);
timer = 0;
return;
}
if (timer % 2 == 0){
drawMoreRects();
} else {
drawWhiteRects();
}
}
1