Why can't I use the back button in state 2?

I want to go back to start 0 when I’m in start 2, why is that not possible?

Code::point_down:

float mainx1 = 300;
float mainy1 = 400;
float mainw1 = 500;
float mainh1 = 250;
float mainx2 = 900;
float mainy2 = 400;
float mainw2 = 500;
float mainh2 = 250;
float bx = 100;
float by = 100;
float bw = 50;
float bh = 50;
int start = 0;
int sekunde;
int minute;
int stunde;
int tag;
int monat;
int yahr;

void update(){
  sekunde = second();
  minute = minute();
  stunde = hour();
  tag = day();
  monat = month();
  yahr = year();
}

void setup(){
  orientation(LANDSCAPE);
  fullScreen();
  frameRate(90);
}
  
void draw(){
  if(start==0){
    background(0);
    fill(255);
    rect(mainx1,mainy1,mainw1,mainh1);
    rect(mainx2,mainy2,mainw2,mainh2);
    if(mousePressed){
      if(mouseX>mainx1 && mouseX <mainx1+mainw1 && mouseY>mainy1 && mouseY <mainy1+mainh1){
        delay(1000);
        start = 2;
      }
    }
    if(mousePressed){
      if(mouseX>mainx2 && mouseX <mainx2+mainw2 && mouseY>mainy2 && mouseY <mainy2+mainh2){
        delay(1000);
        start = 1;
      }
    }
  if(start == 2){
    background(0);
    rect(bx, by, bw, bh);
    textSize(50);
    text("Fenster2", 500, 500);
    if(mousePressed){
      if(mouseX>bx && mouseX <bx+bw && mouseY>by && mouseY <by+bh){
        print("lol");
      }
    }
  }
  if(start == 1){
    background(0);
    update();
    textSize(200);
    String s = String.valueOf(tag);
    fill(#FFFFFF);
    update();
    text(s, 750, 450);
    text(".", 850, 450);
    s = String.valueOf(monat);
    update();
    text(s, 900, 450);
    text(".", 1000, 450);
    s = String.valueOf(yahr);
    update();
    text(s, 1050, 450);
    textSize(75);
    s = String.valueOf(sekunde);
    update();
    text(":", 1157, 595);
    text(s, 1175, 600);
      if(sekunde<10){
        fill(0);
        rect(1175, 540, 90, 70);
        fill(#FFFFFF);
        text("0", 1175, 600);
        text(s, 1220, 600); 
    }
    s = String.valueOf(minute);
    update();
    text(s, 1075, 600);
    text(":", 1055, 595);
    s = String.valueOf(stunde);
    update();
    text(s, 975, 600);
    update();
    orientation(LANDSCAPE);
    }
  }
}
2 Likes

first don’t use mousePressed as a variable, use it as a function mousePressed(); the difference is in the brackets() - see reference

second:

if(start==0){
........
if(start == 2){
...........

better make if…else if…else if… for the entire things

if(start==0){
........
}else if(start == 2){
...........
}
2 Likes

I dont understand this i started processing a week ago can you send me this code?:sweat_smile::heart:

Pls

1 Like

Welcome to processing!

Please show your attempt as code

1 Like

I come in the 2 but I can not click on the back bottun😅

1 Like

Okey wait 2 Minute​:joy::joy::joy:

1 Like

Überprüfe bitte, wo diese Klammern { wieder geschlossen werden:

Ist das richtig so?

void draw() {
  
  if (start==0) {
1 Like

Can you speak german?

1 Like

where do you think do you say start=0; ?

Ich spreche auch Deutsch

2 Likes

Okey gut also ich will das so machen ich öffne das Programm bin in dem Fenster “start 0” dann klicke ich auf das rechte fenster womit ich “start 2” öffne und wenn ich in start 2 bin will ich ein bottun machen womit ich wieder in das Auswahl fenster komme aber wenn ich das mache und da drauf drücke dann passiert nix

Edit: es ist schwer zu erklären

1 Like

I see that you give the seconds a leading zero
(like 03 instead of 3)

you can just say String sa = nf(seconds(), 2);

1 Like

where do you think do you say start=0; ? Because that’s “go back to start 0”.

you just print lol !!!

1 Like

statt einzelne text()

    text(s, 750, 450);
    text(".", 850, 450);

kannst du sagen

text(s + ".", 750, 450);

3 Likes

Ich schreib das wie ich es meine

1 Like

So meine ich das😂

float mainx1 = 300;
float mainy1 = 400;
float mainw1 = 500;
float mainh1 = 250;
float mainx2 = 900;
float mainy2 = 400;
float mainw2 = 500;
float mainh2 = 250;
float bx = 100;
float by = 100;
float bw = 50;
float bh = 50;
int start = 0;
int sekunde;
int minute;
int stunde;
int tag;
int monat;
int yahr;

void update(){
  sekunde = second();
  minute = minute();
  stunde = hour();
  tag = day();
  monat = month();
  yahr = year();
}

void setup(){
  orientation(LANDSCAPE);
  fullScreen();
  frameRate(90);
}
  
void draw(){
  if(start==0){
    background(0);
    fill(255);
    rect(mainx1,mainy1,mainw1,mainh1);
    rect(mainx2,mainy2,mainw2,mainh2);
    if(mousePressed){
      if(mouseX>mainx1 && mouseX <mainx1+mainw1 && mouseY>mainy1 && mouseY <mainy1+mainh1){
        delay(1000);
        start = 2;
      }
    }
    if(mousePressed){
      if(mouseX>mainx2 && mouseX <mainx2+mainw2 && mouseY>mainy2 && mouseY <mainy2+mainh2){
        delay(1000);
        start = 1;
      }
    }

  if(start == 2){
    background(0);
    rect(bx, by, bw, bh);
    textSize(50);
    text("Fenster2", 500, 500);
    if(mousePressed){
      if(mouseX>bx && mouseX <bx+bw && mouseY>by && mouseY <by+bh){
        delay(500);
        start = 0;
        background(0);
      }
    }

  }
  if(start == 1){
    background(0);
    update();
    textSize(200);
    String s = String.valueOf(tag);
    fill(#FFFFFF);
    update();
    text(s, 750, 450);
    text(".", 850, 450);
    s = String.valueOf(monat);
    update();
    text(s, 900, 450);
    text(".", 1000, 450);
    s = String.valueOf(yahr);
    update();
    text(s, 1050, 450);
    textSize(75);
    s = String.valueOf(sekunde);
    update();
    text(":", 1157, 595);
    text(s, 1175, 600);
      if(sekunde<10){
        fill(0);
        rect(1175, 540, 90, 70);
        fill(#FFFFFF);
        text("0", 1175, 600);
        text(s, 1220, 600); 
    }
    s = String.valueOf(minute);
    update();
    text(s, 1075, 600);
    text(":", 1055, 595);
    s = String.valueOf(stunde);
    update();
    text(s, 975, 600);
    update();
    orientation(LANDSCAPE);
    }
  }
}
1 Like

Echt danke das du mir hilfst☺

2 Likes

nochmal:

wo schließt diese geschweifte Klammer { von if (start==0) { ?

Du kannst es sehen, wenn du den cursor direkt neben die Klammer platzierst,
dann leuchtet die dazugehörige schließende Klammer } auf!!!

Ist es die richtige Klammer???

Oder hast du die Klamer } falsch gesetzt???

1 Like

yahr schreibt man Jahr

delay(1000); würde ich löschen

2 Likes

Die Klammer ist die ganze vorletzte im code

1 Like

Aha!

Ist das falsch oder richtig??

Wenn falsch: löschen und statt dessen eine neue } an der richtigen Stelle setzen.

2 Likes