Nub question: Need help with making/changing an (image) button
in
Programming Questions
•
1 month ago
I just started to learn processing like 2 days ago, so please bear over with me :)
I haven't made it too far on this "project". I'm trying to make one image being replaced by clicking on it with the mouse.
PS. could someone also explain the mouseX and mouseY to me? I know it's the current location of wherever the mouse is but I don't understand how to use that for telling the mousePressed as to where it's actually clicking. I also don't understand the y+height and x+width (which can explain why the code below might not make all that much sense as to my mouseX and mouseY values), to me it sounds like if x=100 then it's 100+the width which I guess is the void setup size? Which makes no sense to me...
Thanks in advance! <3
void setup() {
size(600,400);
background(255);
image(loadImage("black_arrow_left.gif"),100,100);
//image(loadImage("black_arrow_right.gif"),300,100);
}
void mousePressed() {
if (mouseX >= 100 && mouseX <= 10+width &&
mouseY >= 100 && mouseY <= 10+height ) {
image(loadImage("blue_arrow_left.gif"),100,100);
}
}
1