Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Using G4P GUI image buttons, how to use mouse pressed on the button, and make them go away after

$
0
0

I want my first page to have the image buttons i created with my gui, but then I want to create some sort of boolean/ mouse clicked when you click on them it'll change my programs page ( and the buttons will disapear). Is anyone familiar with this editor and can help me?

// Need G4P library
import g4p_controls.*;
int page=1;

int otisX, otisY= 200;
int maxX= 700;
int maxY= 200;

int W= 600, H= 600;

boolean OtisOver= false;
boolean MaxOver= false;

public void setup() {
  size(800, 600, JAVA2D);
  createGUI();
  customGUI();
}

public void draw() {
  page1();
  background(200);
  //pageSelector();
}


void pageSelector() {
  if (page==1) {
    page1();
  } else if (page==2) {
    page2();
  } else {
    page3();
  }
}
void page1() {
  background(#FF00FF);
  fill(250);
  rect(otisX, otisY, W, H);
  rect(maxX, maxY, W, H);
}
void page2() {
  background(#CE2121);
}
void page3() {
  background(#008000);
}
void mousePressed() {
  if (OtisOver (otisX, otisY, W, H)==true) {
    page2();
  }
  if (MaxOver (maxX, maxY, W, H)==true) {
    page3();
  }
}


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

boolean OtisOver(int x, int y, int w, int h) {
  if (mouseX >= x && mouseX <= x+w &&
    mouseY >= y && mouseY <= y+h) {
    return true;
  } else {
    return false;
  }
}
public void customGUI() {
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles