Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How come the sounds won't reload in "paths" code (but images do?)

$
0
0

Hello,

I am a teacher helping my students complete their projects for a 12th grade exhibition. In this project, there are 4 roll-over photos and sounds in path 1. When we cycle through to path 0 and then path 1 again, the photo roll-overs work but the sounds don't. Looking for advice - thank you!!!

PImage photo1;
PImage photo2;
PImage photo3;
PImage photo4;
PImage photo5;
PImage photo6;
PImage photo7;
PImage photo8;

int path = 0;

import ddf.minim.*;
Minim minim;
AudioPlayer thunder;
AudioPlayer thunder2;
AudioPlayer thunder3;
AudioPlayer thunder4;


void setup(){
  size (1000,700);
  photo1 = loadImage ("StartScfinal.png");
  photo2 = loadImage ("goodcopbadcop.png");
  photo3 = loadImage ("stereotypes.png");
  photo4 = loadImage ("goodcopbadcopfettyfettywap.png");
  photo5 = loadImage ("goodcopbadcophatecrimes.png");
  photo6 = loadImage ("goodcopbadcopsikhsikh2.png");
  photo7 = loadImage ("latinomanlm.png");
  photo8 = loadImage ("newbolt.png");

 minim = new Minim(this);
 thunder = minim.loadFile ("thunderthunder.mp3");
    thunder2 = minim.loadFile ("thunderthunder2.mp3");
      thunder3 = minim.loadFile ("thunderthunder3.mp3");
       thunder4 = minim.loadFile ("thunderthunder4.mp3");

}

  void draw(){
    println(mouseX,mouseY);
    println ("path=",path);

    if (path == 0) {
      imageMode(CENTER);
      image (photo1,500,350);
      cursor (HAND);
    if ((mousePressed) && (mouseX > 178) && (mouseX < 805) && (mouseY > 524) && (mouseY < 593)){
      path = 1;
    }
    }
    if (path == 1) {
      cursor(photo8);
    {
      image (photo2,500,350,1000,700);
      imageMode(CENTER);
  }
    if ((mouseX > 153) && (mouseX < 250) && (mouseY > 402) && (mouseY < 578)){
      thunder.play();
      image (photo6,500,350,1000,700);
  }
    if ((mouseX > 541) && (mouseX < 612) && (mouseY > 373) && (mouseY < 544)){
      image (photo4,500,350,1000,700);
      thunder2.play();
  }
    if ((mouseX > 912) && (mouseX < 969) && (mouseY > 384) && (mouseY < 539)){
      image (photo7,500,350,1000,700);
      thunder3.play();
  }
    if ((mouseX > 820) && (mouseX < 881) && (mouseY > 375) && (mouseY < 575)){
      image (photo5,500,350,1000,700);
      thunder4.play();

    }

  }
  if (path == 1) {
    if (keyPressed == true){
      path = 0;
    }
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles