mousePressed() function

When you use background() at the beginning of draw() - which runs 60 times per second - the circle drawn in mousePressed() gets deleted immediately

There are several different ways to solve this :

  • You could delete the background line

  • You could set a global boolean variable mouseHasBeenPressed to true in mousePressed() and then check it with if() in draw() and paint the circle there if the condition is met. Using the variable makes the decision in mousePressed() permanent.

Chrisir

3 Likes