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
imageButtons (Read 391 times)
imageButtons
Jul 21st, 2008, 6:48pm
 
In creating imageButtons that run a boolean when you press them, is this the correct format?

PImage Magic= loadImage("Magic.png");
button = new ImageButtons(Magic);
Re: imageButtons
Reply #1 - Jul 21st, 2008, 9:15pm
 
Assuming you are using the example showed on this page :

http://processing.org/learning/examples/imagebutton.html

Then, your ImageButtons instance's constructor need more arguments :

Code:
ImageButtons(
int topLeftCornerX,
int topLeftCornerY,
int buttonWidth,
int buttonHeight,
PImage buttonImage,
PImage buttonImageWhenMouseOver,
PImage buttonImageWhenMousePressed
)


so something like :

Code:
button = new ImageButtons(
10, 10, 30, 10,
loadImage("button.png"),
loadImage("buttonOver.png"),
loadImage("buttonDown.png")
)
Re: imageButtons
Reply #2 - Jul 21st, 2008, 10:01pm
 
If the image simply remains the same whether mouseOver or mousePressed, wouldn't I keep the same image for both those load Image commands?
Re: imageButtons
Reply #3 - Jul 21st, 2008, 11:20pm
 
Yes. In this case just give the same reference for the three parameters :

Code:
PImage Magic= loadImage("Magic.png");  
button = new ImageButtons(10, 10, 30, 10, Magic, Magic, Magic);
Page Index Toggle Pages: 1