We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, I'm super new to Processing so the solution is probably something obvious.
I'm trying to create a sketch which wouldplay a show a different image and play a different song depending on where the mouse is positioned. I managed to write a code which would work depending where the mouse is pressed. So i decided to use that same code but to try and make it work depending on where the mouse is postioned. But when i took away the "void mousepressed' function and joined the code into "void draw" only the images change with the position of the mouse, the audiofiles don't really play... Only the first couple of seconds of the first audio plays before restarting itself and whenever I move the mouse around i can hear random low noises (i guess of the audios trying to play, i'm not sure). I'm super confused by this and would be grateful if anyone could help me!
Answers
Here is my code:
PImage img;
import ddf.minim.*;
AudioPlayer player;
Minim minim;
void setup() {
size(600, 400);
img = loadImage("image1.jpg");
img = loadImage("image2.jpg");
img = loadImage("image3.jg");
img = loadImage("image4.jpg");
img = loadImage ("image5.jpg");
minim = new Minim(this);
player = minim.loadFile("audio1.mp3");
minim = new Minim(this);
player = minim.loadFile("audio2.mp3");
minim = new Minim(this);
player = minim.loadFile("audio3.mp3");
minim = new Minim(this);
player = minim.loadFile("audio4.mp3");
minim = new Minim(this);
player = minim.loadFile("audio5.mp3");
}
void draw() {
image(img, 0, 0, width, height);
if(mouseX<width/5) {
}
else if (mouseX<width/4) {
}
else if(mouseX<width/3){
}
else if (mouseX<width/2) {
}
else if (mouseX<width/1) {
}
else {
}
}
void stop() {
player.close();
minim.stop();
super.stop();
}