Hey guys!. Can you all please help me of how to make a confirmation window before exiting the sketch with the options ‘Yes’ and ‘No’ in Processing 3.0 Java? Here is my simple code:
boolean correct[] = {false,false};
void setup(){
fullScreen();
smooth(2);
}
void draw(){
background(0);
translate(width/2, height/2);
if(key==‘e’){
correct[1]=true;
confirm();
if (key==‘n’){
correct[0]=false;
if(key==‘y’&&correct[0]==false){
key=0;
}
}else if(key==‘y’){
correct[0]=true;
}
}
if(key==‘y’&&correct[0]==true){
super.stop();
exit();
}
if(key==‘y’&&correct[0]==false){
key=0;
}
}
void confirm(){
stroke(255);
textSize(20);
text(“Do you really want to exit?”, -125, 0);
if(key==‘y’&&correct[0]==true){
super.stop();
exit();
}
if(key==‘y’&&correct[0]==false){
key=0;
}
}