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
In my code, i have six images that i want to drag and drop, but i want them to drag and drop separately. Right now when i drag one image all images move simultaneously. Can anyone help me make them drag and drop separately?
Here's the code:
PImage img1;
PImage img;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
PImage img10;
PImage img11;
PImage img12;
PImage img13;
PImage img14;
PImage img15;
PImage img16;
PImage img17;
PImage img18;
PImage img19;
PImage img20;
PImage img21;
PImage img22;
float rockX;
float rockY;
float rockZ;
float rockW;
float rockA;
float rockB;
float rockC;
float rockD;
float rockE;
float rockF;
float rockG;
float rockH;
float watermelonX;
float watermelonY;
boolean rockDragging;
void setup() {
size (700, 700);
rockX = 150;
rockY = 400;
rockZ = 200;
rockW = 400;
rockA = 250;
rockB = 400;
rockC = 150;
rockD = 370;
rockE = 200;
rockF = 370;
rockG = 250;
rockH = 370;
watermelonX = 250;
watermelonY = 600;
rockDragging = false;
img1 = loadImage("background2.jpg");
img = loadImage("house.png");
img2 = loadImage("watermelon back.png");
img3 = loadImage("rock.png");
img4 = loadImage ("rock2.png");
img5 = loadImage("rock3.png");
img6 = loadImage ("rock4.png");
img7 = loadImage("rock5.png");
img8 = loadImage ("rock6.png");
img9 = loadImage("rock7.png");
img10 = loadImage ("rock8.png");
img11 = loadImage("rock9.png");
img12 = loadImage ("rock10.png");
img13 = loadImage("rock11.png");
img14 = loadImage ("rock12.png");
img15 = loadImage("rock13.png");
img16 = loadImage ("rock14.png");
img17 = loadImage("rock15.png");
img18 = loadImage ("rock16.png");
img19 = loadImage("rock17.png");
img20 = loadImage ("rock18.png");
img21 = loadImage("rock19.png");
img22 = loadImage ("rock20.png");
background (#2BD8ED);
}
void mousePressed()
{
if (mouseInRock (rockX, rockY, 60, 50));
if (mouseInRock (rockZ, rockW, 60, 50));
if(mouseInRock (rockA, rockB, 60, 50));
if (mouseInRock (rockC, rockD, 60, 50));
if (mouseInRock (rockE, rockF, 60, 50));
if (mouseInRock (rockG, rockH, 60, 50));
if (mouseInRock (watermelonX, watermelonY, 150, 80));
In my code, i was able to make the second image appear on top of the first image when the mouse is pressed, but it goes away when the mouse is released. How do i make the second image stay? and is there a way to make the first image underneath disappear? or change the transparency of it or something when the mouse is pressed?