if(toggle == 1){
fill(150,10);
rect(width+435,400,200,height);
fill(0);
textSize(20);
text(" R = Restart",1120,500);
}
}
}
void keyPressed()
{
if(key=='R' || key == 'r')
{
}
}
I have done everything that I know and still haven't reached a point. I have done and approached my problem with a lot of methods and neither one of them was true for my case.my problem is with the r which stands for restart the sketch.
Your sketch depends on
frameCount
. Resetting the sketch would mean resetting theframeCount
. Unfortunately, theframecCunt
cannot be reset. You have to implement your ownframeCount
:Add a variable:
Increment the variable every frame and replace
frameCount
withmyFrameCount
in your code:Reset the
myFrameCount
when r is pressed:Complete code: