mousePress Animation Toggle - Help!
in
Programming Questions
•
2 years ago
Hello!
I had solved a previous problem of toggling an animation of a concentric circle to grow and stop on a mousePress event, but now I'd like the stop/start of the event to happen when you click the circle, and not just anywhere on the sketch. Here's my code:
- int mil1 = 1;
- void setup() {
- size(200,200);
- smooth();
- }
- void draw() {
- background(0);
- if(mil1 > 95) {
- mil1 = 1;
- } else if (mil1 >= 1) {
- mil1 += 2;
- }
- //Circle ACTIVE RED 1
- noFill();
- stroke(255,0,0);
- strokeWeight(4);
- ellipse(100,100, 30*3.333,30*3.333);
- fill(255,0,0);
- stroke(255,0,0);
- strokeWeight(4);
- ellipse(100,100, mil1,mil1);
- }
- void mousePressed() {
- if (mil1 >= 1) {
- mil1 = 0;
- } else if (mil1 == 0) {
- mil1 = 1;
- }
- }
1