I want to make a photo slideshow
in
Programming Questions
•
6 months ago
Hi geeks!
I tried to make a photo slideshow with some button functions,
but there is some problem with it.
I don't know why.
Could anyone have a look at this. I don't think its a complex problem.
Thanks!
Here is the code:
I tried to make a photo slideshow with some button functions,
but there is some problem with it.
I don't know why.
Could anyone have a look at this. I don't think its a complex problem.
Thanks!
Here is the code:
- boolean isImage3= false;
- boolean isImage2= false;
- boolean isImage1= true;
- PImage img1;
- PImage img2;
- PImage img3;
- void setup(){
- size(500, 500);
- img1 = loadImage("1.jpg");
- img2 = loadImage("2.jpg");
- img3 = loadImage("3.jpg");
- }
- void draw(){
- background(255);
- if(isImage1){
- image1();
- }
- else if(isImage2){
- image2();
- }
- else if(isImage3){
- image3();
- }
- }
- void image1(){
- image(img1, 0, height/6,640,360);
- fill(150);
- rect(20,height/2,20,50);
- rect(width-40,height/2,20,50);
- }
- void image2(){
- image(img2, 0, height/6,640,360);
- fill(150);
- rect(20,height/2,20,50);
- rect(width-40,height/2,20,50);
- }
- void image3(){
- image(img3, 0, height/6,640,360);
- fill(150);
- rect(20,height/2,20,50);
- rect(width-40,height/2,20,50);
- }
- void mousePressed(){
- if(isImage1){
- if(mouseX > 20 && mouseX<40 && mouseY > height/2 && mouseY< height/2+50){
- isImage1=false;
- isImage3 =true;
- }
- else if(mouseX > width-40 && mouseX<width-20 && mouseY > height/2 && mouseY< height/2+50){
- isImage1=false;
- isImage2 =true;
- }
- //if images button is hit
- else {
- isImage1= true;
- }
- }
- if(isImage2){
- if(mouseX > 20 && mouseX<40 && mouseY > height/2 && mouseY< height/2+50){
- isImage2=false;
- isImage1 =true;
- }
- else if(mouseX > width-40 && mouseX<width-20 && mouseY > height/2 && mouseY< height/2+50){
- isImage2=false;
- isImage3 =true;
- }
- //if images button is hit
- else {
- isImage2= true;
- }
- }
- if(isImage3){
- if(mouseX > 20 && mouseX<40 && mouseY > height/2 && mouseY< height/2+50){
- isImage3=false;
- isImage2 =true;
- }
- else if(mouseX > width-40 && mouseX<width-20 && mouseY > height/2 && mouseY< height/2+50){
- isImage3=false;
- isImage1 =true;
- }
- //if images button is hit
- else {
- isImage3= true;
- }
- }
- }
1