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
totrue
inmousePressed()
and then check it withif()
in draw() and paint the circle there if the condition is met. Using the variable makes the decision inmousePressed()
permanent.
Chrisir