Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Clicking an Image to change it to another image

$
0
0

I'm very new to processing and have been trying to figure this out for awhile and I'm sure it is easy but I need help.

All I'm trying to do is turn the jellyfish image to the plastic bag image when it is clicked. I have a couple of jellyfish spread out through the sketch but wanted them to only changed when they are clicked indivdually. Here is the code that I have been working with, I'm very confused on what to put into the void mousePressed()

PImage ocean; PImage jellyfish; PImage bag;

void setup(){ size(1280, 520); //background image PImage ocean; ocean = loadImage("ocean.jpg"); background(ocean);

jellyfish = loadImage("jellyfish.png"); bag = loadImage("plastic_bag.png");

}

void draw(){ image(jellyfish, 500, 120); image(jellyfish, 600, 320); image(jellyfish, 100, 20); image(jellyfish, 1000, 50); }

void mousePressed(){

}

}


Viewing all articles
Browse latest Browse all 2896

Trending Articles