We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › mouseClick() help
Page Index Toggle Pages: 1
mouseClick() help (Read 973 times)
mouseClick() help
Apr 19th, 2010, 12:15pm
 
Hey guys, I just need help trying to get to where only the image i click on enlarges in this code I have put together.. Thanks! I figure I need to fidle around with the mouse xy functions but when I did nothing would happen.

boolean makeLarge;
boolean makeLarge_bat;
boolean makeLarge_mask;
boolean makeLarge_pnut;
PImage bat;
PImage Mask;
PImage jpg_bat;
PImage jpg_mask;

void setup()
{
 size(500, 500);
 smooth();
 fill(255,255,255);
 textFont(createFont("sansSerif",32));
 textAlign(CENTER);

 bat = loadImage("Bat_face.jpg");

 Mask = loadImage("Mask.jpg");

 jpg_bat = loadImage("bat.jpg");

 jpg_mask = loadImage("tribal.jpg");

}

void draw() {
 background(0);
 text("Click On An Image!", width/2, height/2);
// image(jpg_bat, 380,380, 140, 140);

 if (makeLarge)
 {
   image(Mask, 10, 10, 210, 210);

 }
 else
 {
   image(Mask, 10, 10, 70, 70);

 }
 if (makeLarge_bat){
   image(bat, 10,300, 210, 210);
 }
 else{
   image(bat,10,419,70,70);
 }
 if (makeLarge_mask){
   image(jpg_mask,280,10,210,210);
 }
 else{
   image(jpg_mask,415,10,70,70);
 }
 
  if(makeLarge_pnut){
    image(jpg_bat,280,280,240,240);
  }
   else{
     image(jpg_bat,380,380,140,140);
   }
}

void mousePressed()
{
 makeLarge = true;
 makeLarge_bat = true;
 makeLarge_mask = true;
 makeLarge_pnut = true;


}

void mouseReleased()
{


 makeLarge = false;
 makeLarge_bat = false;
 makeLarge_mask = false;
 makeLarge_pnut = false;


}
Re: mouseClick() help
Reply #1 - Apr 19th, 2010, 3:11pm
 
You need to check the mouse coordinates are within the bounds of the image when the mouse is clicked.  However you'd then also need separate booleans for each image...

This might be a good time to explore Object.  They're perfect for this kind of thing...
Page Index Toggle Pages: 1