We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it safe to make a method loop like in the code bellow, or is it better to just use a boolean in draw()?
Loop in method:
void menu() {
// do some stuff
//if you didn't get the results that you wanted:
If(value != 10) {
Menu();
}
}
Or control in draw?
void draw() {
If(control == true) {
// do some stuff
//if you got the results that you wanted:
If(value == 10) {
control = false;
}
}
else {
\\ rest of code
}
}
Answers
I don't think it matters in your case because I don't see any loop, unless you are calling
menu()
from draw continually. Also just a tip, java is very lenient about spacing but it is extremely case-sensitive. Like when you callMenu()
on line 6 or sayIf(...)
in the second example, be very careful. Processing could give you an error.there's a recursive call in menu, perhaps he means that?
I'd avoid recursive calls generally. can't tell by the sample what you're trying to do but, generally a while loop is safer.