Hi!
I am trying to delay expanding ball 2 so that it starts expanding after expanding ball 1. I have tried the pushMatrix(); and popMatrix(); which made my program crash and I also tried the delay example on the processing website: delay() / Reference / Processing.org . But couldn’t find out how to make it work. Would love some help if anyone knows how to fix this! :))
<
int tracker;
float fade = 200;
float d = 25;
float d2 = 25;
float count = 0;
int step = 1;
int max = 150;
int max2 = 75;
void setup (){
frameRate (30);
size (1000,1000);
background (255);
noStroke();
fill(0);
}
void draw() {
background (255);
fill (200);
noStroke();
if (tracker>20){
ellipse(580,500,25,25);
fill(fade,fade,fade);
noStroke();
fade=fade-0.9;
}
fill(0);
noStroke();
circle(515,520,d); //expanding ball 1
count = count+1;
d = d + step;
if (d > max){
d = max;
}
circle(600,780,d2); //expanding ball 2
d2 = d2 + step;
if (d2 > max2){
d2 = max2;
}
}
<
mnse
August 15, 2022, 7:43am
2
Hi @Isobelcameron ,
would you first please format you code according to this section
https://discourse.processing.org/faq#format-your-code
Cheers
— mnse
It think it’s not about speed.
It’s more about animating one thing when the first thing is finished.
There are a lot of ways to do this.
One idea is that you set a marker (boolean) and evaluate it. Only when it’s true, the second ball growth
mnse
August 15, 2022, 12:36pm
4
Hi @Isobelcameron ,
Here’s an example of how you can do …
(the code is lengthily written for demonstration, and could be written quite more compact)
Cheers
— mnse
int d1 = 1;
int d1step = 2;
int d1max;
int d2 = 1;
int d2step = 2;
int d2max;
int direction = 1;
void setup() {
size(500, 500);
d1max = d2max = width/2;
}
void draw() {
background(0);
if (direction > 0) {
if (d1 < d1max) {
d1 += d1step;
} else if (d2 < d2max) {
d2 += d2step;
} else {
direction *= -1;
d1step *= -1;
d2step *= -1;
}
} else {
if (d1 > 1) {
d1 += d1step;
} else if (d2 > 1) {
d2 += d2step;
} else {
direction *= -1;
d1step *= -1;
d2step *= -1;
}
}
circle(width*.25, height*.5, d1);
circle(width*.75, height*.5, d2);
}
1 Like
Thank you so much! that looks great will definitely implement that into my code