How can I load the image? (mousePressed, case)

After the ‘start’ image appears in case2, I want case3 to appear when I press a certain part. But case3 is not loaded. What could be the problem?

import processing.video.*;
Movie intro;

int caseNum=1;
PImage start;
PImage press;
PImage cloth1;
boolean btn1=false;

void setup() {
  size (1423, 800);
  intro=new Movie(this, "intro.mp4 ");
  intro.play();
  start=loadImage("start.png");
  press=loadImage("press.png");
  cloth1=loadImage("cloth1.png");
}

void draw() {
  println(caseNum);
  
  switch(caseNum) {
  case 1:
    image(intro, 0, 0, width, height);
    println(intro.time());
    if (intro.time()>=16) {
      caseNum=2;
    }
    break;

  case 2:
    image(start, 0, 0);
    image(press, 500, 620);
       if (mouseX>500 && mouseX<953&&mouseY>620&& mouseY<692) {
      btn1=true;
    } else {
      btn1=false;
   }
    break;

  case 3:
    image(cloth1, 0, 0);
    break;
  }
}


void mousePressed() {
  switch(caseNum) {
    case 2:
    if (btn1==true) {
      caseNum=3;
    }
    break;
  }
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
}
1 Like

Delete this…?

Chrisir

It didn’t work T.T
But thanks alot!

You don’t need the variable btn1 at all

Move the if(mouseX...) part into the function mousePressed() and change caseNum (also referered to as a “state” by the way) there