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.
Page Index Toggle Pages: 1
object hover (Read 938 times)
object hover
Feb 17th, 2010, 10:06pm
 
Hello,

I'm making a program where part of it is to have a button change tint when the mouse hovers over it. I am making my 'button' an image instead of say a rectangle. But when I hove over it, the entire image is getting tinted instead of just the one, I checked the order of operations and I'm not sure why it happened.
Code:

if (overButton(530, 280, rabbit.width, rabbit.height) == true){
     tint(255, 0, 0);
     image(rabbit, 530, 280);
     noTint();
     image(page1, 0, 0);
   }else{
     noTint();
   }  


And rabbit is just the image, here is 'overButton':
Code:

boolean overButton(int x, int y, int w, int h){
 if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
   return true;
 }
 else {
   return false;
 }
}


I put the image of page1 after the rabbit, but either way the whole thing gets tinted as of now.

Thanks for any help!~
Re: object hover
Reply #1 - Feb 18th, 2010, 12:15am
 
Just tested with:
Code:
image(img, 0, 0);
tint(255, 0, 0);
image(img, 200, 0);
noTint();
image(img, 400, 0);
in default mode, and the last image is identical to first one while the middle one is tinted.
The problem might be elsewhere.
Re: object hover
Reply #2 - Feb 18th, 2010, 2:29am
 
When you write "the entire image is getting tinted instead of just the one", what do you mean by the "entire image" and "just the one"?

Is something other than the "rabbit" button being tinted?

Does the tinting disappear when you move the mouse away from the rabbit button?

-spxl
Re: object hover
Reply #3 - Feb 19th, 2010, 2:26pm
 
Thanks, i actually just changed it so the full image is labeled as a background instead of an image, and the 'button' is an image layer on top of that. I guess it was an ordered issue.
Page Index Toggle Pages: 1