Hello,
Hard to explain, but here's the code 1st:
Code:import gifAnimation.*;
import ddf.minim.*;
Minim minim;
AudioSnippet songR;
AudioSnippet songL;
int albumSize = 3;
int albumsize = 30;
int selectedPhoto = 0;
int selected = 0;
PImage[] photoAlbum;
PImage[] photo;
int timer;
Gif loopingGif;
int toestand = '1';
void setup() {
photo = new PImage[albumsize];
photoAlbum = new PImage[albumSize];
size(1024, 768);
photoAlbum[0] = loadImage("1.png");
photoAlbum[1] = loadImage("2.png");
photoAlbum[2] = loadImage("3.png");
for(int i = 0;i<albumsize;i++){
photo[i] = loadImage((i+1)+".jpg");
}
frameRate(3);
loopingGif = new Gif(this, "LoadScreen.gif");
loopingGif.loop();
timer = 0;
imageMode(CENTER);
minim = new Minim(this);
songR = minim.loadSnippet("rechts.wav");
songL = minim.loadSnippet("links.wav");
}
void draw() {
timer++;
image(loopingGif, width/2, height/2);
if(timer>=15){
switch (toestand){
case '1':
if (photoAlbum[selectedPhoto] != null) {
image(photoAlbum[selectedPhoto], width/2, height/2);
}
break;
case '2':
if (photo[selected] != null) {
image(photo[selected], width/2, height/2);
}
break;
}
}
}
void keyReleased() {
if(key ==',') {
songR.play();
songR.rewind();
if(selectedPhoto < 1) {
selectedPhoto = photoAlbum.length - 1;
} else {
selectedPhoto--;
}
}
if(key=='m') {
int toestand ='2';
println(selected);
}
if (key == '.') {
songL.play();
songL.rewind();
if(selectedPhoto > photoAlbum.length - 2){
selectedPhoto = 0;
} else {
selectedPhoto++;
}
}
println(selectedPhoto);
if (key ==',') {
if(selected < 1) {
selected = photo.length - 1;
}
else {
selected--;
}
}
if (key =='.') {
if(selected > photo.length - 2) {
selected = 0;
} else {
selected++;
}
}
}
}
Don't mind the looping gif, because thats not important right now, but I've got a question about using 2 buttons at the same time to go somewhere. As you can see, there are already 2 keys declared to do something. , is used to go to the previous picture and . is declared to go to the next picture. But now I'd like to press . and , at the same time so that they go to another loop of pictures. (That's what
Code: for(int i = 0;i<albumsize;i++){
photo[i] = loadImage((i+1)+".jpg");
}
is for. It's the other loop.)
If i do if (key =='.' && key==',') it just doesn't work. It does nothing. Can someone help me?
Thanks in advance