Hello i'm a total newbie at this so I dont know squat but we are doin a projekt in school and i need help to learn how to do multiple image buttons? But it says my imageButton2 is undefined, why?? I have come this far:
ImageButtons1 button1;
ImageButtons2 button2;
PImage bg;
void setup()
{
size(778,597);
bg = loadImage("Bild_001_asdf.JPG");
background(bg);
PImage b = loadImage("knapparva.JPG");
PImage r = loadImage("rollva.JPG");
PImage d = loadImage("clickva.JPG");
int x = 526;
int y = height - b.height;
int w = b.width;
int h = b.height;
button1 = new ImageButtons1(x, y, w, h, b, r, d);
}
{
PImage bf = loadImage("knapparfr.JPG");
PImage rf = loadImage("rollfr.JPG");
PImage df = loadImage("clickfr.JPG");
int xf = 600;
int yf = height/2 - bf.height/2;
int wf = bf.width/2;
int hf = bf.height/2;
button2 = new ImageButtons2(xf, yf, wf, hf, bf, rf, df);
}
boolean overRect(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
} else {
return false;
}
}
}
class Button2
{
int xf, yf;
int wf, hf;
color basecolor, highlightcolor;
color currentcolor;
boolean over = false;
boolean pressed = false;
ImageButtons1(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown)
{
x = ix;
y = iy;
w = iw;
h = ih;
base = ibase;
roll = iroll;
down = idown;
currentimage = base;
}
ImageButtons1(int ixf, int iyf, int iwf, int ihf, PImage ibase, PImage iroll, PImage idown)
{
x = ixf;
y = iyf;
w = iwf;
h = ihf;
base = ibase;
roll = iroll;
down = idown;
currentimage = base;
}