making mouse pressed stay
in
Programming Questions
•
6 months ago
In this code, i have three images that i want to appear when the mouse is pressed. I want to be able to click on the first image to make the second image appear, and then click on the second image to make the third image appear. Right now when i click on the first image, the second image appears, but it doesn't stay. Can anyone help me with this?
Here's the code:
//variables for clouds
float cloudX = 1;
float cloudMoveX = 1;
boolean showStory;
boolean showStory2;
PImage img;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img34;
void setup () {
size (700, 700);
//images for page 1
img = loadImage("Background.jpg");
img2 = loadImage("sad watermelon.png");
img3 = loadImage("thought.png");
img4 = loadImage ("family.png");
img5 = loadImage ("Cloud.gif");
img6 = loadImage ("Cloud2.gif");
img7 = loadImage ("Cloud3.gif");
img34 = loadImage ("family-2.png");
}
void draw ()
{
//draws the still images
image(img, 0, 0, 700, 700); //background
image (img2, 200, 350, 300, 175); //watermelon
//moves the clouds (taken from my week 5 assignment - values changed)
cloudX =cloudX + cloudMoveX;
if (cloudX == 70) {
cloudMoveX = -1;
}
if (cloudX == 50) {
cloudMoveX = 1;
}
image(img5, cloudX, 30, 150, 100); //cloud
image(img6, cloudX+100, 120, 100, 100); //cloud
image(img7, cloudX+200, 50, 100, 100); //cloud
//draws window outline
noFill();
stroke(0);
strokeWeight(10);
rect (60, 60, 305, 295);
//makes thought bubble appear when user clicks on watermelon
//makes text box appear when user clicks on the family
if (mousePressed) {
if ( mouseX >= 220 && mouseX <= 460) {
if ( mouseY >= 370 && mouseY <= 500) {
showStory = true;
println(showStory);
}
}
if (showStory) {
image (img3, 370, 40, 350, 350); //thought bubble
image (img4, 450, 60, 200, 200); //family
}
if (mousePressed && mouseX == 370 && mouseY == 40) {
showStory = false;
showStory2 = true;
println("yes");
}
if (showStory2) {
fill (255);
noStroke();
rect (15, 520, 670, 150);
fill (0);
textSize(14);
text("Watermelon’s wife, Strawberry and his son, Grape", 40, 560);
text("were kidnapped by the evil Vegetable family –", 40, 580);
text("Potato, his wife Beetroot, and his son Broccoli.", 40, 600);
text("Press any key to help him find his family.", 40, 620);
image (img34, 480, 510, 180, 180);
ellipse (650, 650, 50, 50);
}
}
println(mouseX + ", " + mouseY);
}
1