Hi guys,
I need some help to make a button work.
On the one hand I have a little presentation of my program using two scenes.
void setup(){
size(270,540);
background(0,0,0);
noStroke();
smooth();
}
void scene1() {
background(0,0,0);
fill(255, 255, 255, 255);
textSize(height/12);
textAlign(RIGHT, CENTER);
text("deep", width/2, height/2);
fill(255, 204 , 0, 255);
textSize(height/12);
textAlign(LEFT, CENTER);
text("focus", width/2, height/2);
fill(255, 95, 95, 255);
textSize(height/36);
textAlign(CENTER, CENTER);
text("@deepfocusapp", width/2, height/1.1);
}
void scene2() {
String a = "1. Cuenta cada círculo que aparece en la pantalla.";
String b = "2. Cada vez que te distraigas, devuelve tu atención a los círculos que estás contando.";
String c = "Instrucciones.";
background(255);
fill(0);
stroke(255,95,95);
strokeWeight(1);
line(width/10, height/5, width/1.15, height/5);
textAlign(LEFT, TOP);
textSize(height/22);
text(c, width/10, height/10, width/1.2, height/6.66);
textSize(height/33);
text(a, width/10, height/4, width/1.2, height/3.33);
textSize(height/33);
text(b, width/10, height/2.5, width/1.2, height/2.22);
//this is my button
fill(255,95,95);
noStroke();
circle(width/2, height/1.3, height/9);
noFill();
stroke(255);
strokeWeight(3);
circle(width/2, height/1.3, height/16);
noStroke();
fill(255);
circle(width/2, height/1.3, height/80);
}
void draw (){
int m = millis();
if(m < 5000) {
scene1();
} else if(m > 5000) {
scene2();
}
}
Second scene has a button and I want it to activate following animation when you touch it. I thought to create an scene 3 with animation, but I don’t know how to link it with the button.
int cx, cy;
float secondsRadius;
float clockDiameter;
void setup() {
size(270, 540);
stroke(255);
int radius = min(width, height) / 2;
secondsRadius = radius * 0.72;
clockDiameter = radius * 1.8;
cx = width / 2;
cy = height / 2;
}
void draw() {
background(255,95,95);
// Angles for sin() and cos() start at 3 o'clock;
// subtract HALF_PI to make them start at the top
float s = map(second(), 0, 10, 0, TWO_PI);
// Draw the hand of the clock
stroke(255);
strokeWeight(5);
line(cx, cy, cx + cos(s) * secondsRadius, cy + sin(s) * secondsRadius);
// Draw the second ticks
strokeWeight(5);
beginShape(POINTS);
for (int a = 0; a < 360; a+=36) {
float angle = radians(a);
float x = cx + cos(angle) * secondsRadius;
float y = cy + sin(angle) * secondsRadius;
vertex(x, y);
}
endShape();
}
Finally, I want that you can come back to the scene 2 by touching screen. Do you know how can I make it?
Thanks!