Button Won't Return to Original Color. Help please =)
in
Programming Questions
•
6 months ago
Hello all!
I'm trying to create buttons in which when the user mouses over the word, it changes from white to gray (the only word I have this applied to is "About". In theory it should change back to white once the mouse moves away from it, but for some reason it's staying gray. I think there's some small issue in there somewhere that I'm overlooking and I just need a fresh pair of eyes to find my mistake. Any help is greatly appreciated!!!
And my apologies for the tons of code in here. This is an in-progress class project.
// for this project, I'm creating a virtual tour of NIU's art museum along with pages with their information, mission statement and the Arts at NIU.
//For all my images and number values, I'm basing them off the DisplayWidth and DisplayHeight so that they will appear in the same location regardless of the size of the screen the program is run on.
//fonts
PFont arialBold;
PFont arial;
//Home page and exhibit integers
//this integer will organize all the pages for the home page (information, mission, ect.)
int home;
//this integer will organize all the pages for the virtual tour. The two different integers will ensure that the two don't get tangled with each other
int exhibit;
//colors for home buttons and highlights
color homeButtonColor, homeButtonHighlight;
//images for home page
//images for virtual tour
//PImage SouthLobby;
//variables for buttons on home page
float AboutButtonX, AboutButtonY, AboutButtonWidth, AboutButtonHeight;
float ButtonWidth, ButtonHeight;
//booleans for home page buttons
boolean AboutOver = false;
void setup(){
//size of drawing will conform to the width/height of the monitor it's being displayed on
size(displayWidth,displayHeight);
//colors for home page buttons
homeButtonColor = 255;
homeButtonHighlight = 150;
//loading fonts
arialBold = loadFont("Arial-BoldMT-48.vlw");
arial = loadFont("ArialMT-48.vlw");
home = 0; //kiosk will start at the NIU Art Museum page, the "home page"
//Home page button values
AboutButtonX = displayWidth*.23;
AboutButtonY = displayHeight*.37;
AboutButtonWidth = displayHeight/4;
AboutButtonHeight = displayHeight/16;
//SouthLobby = loadImage("S exhibit lobby.JPG");
rectMode(CENTER);
imageMode(CENTER);
noStroke();
}
void draw(){
update(mouseX,mouseY);
//sets up scene for opening page
if (home == 0){
background(180);
fill(0);
rect(displayWidth/2, displayHeight/8, displayWidth, displayHeight/4);
fill(250);
textFont(arialBold, displayHeight*.18);
text("Art Museum", displayWidth*.2, displayHeight*.22);
fill(255,0,0);
textFont(arial, displayHeight*.05);
text("Northern Illinois University", displayWidth*.32, displayHeight*.07);
fill(255);
textFont(arialBold, displayHeight*.08);
// text("About", displayWidth/6, displayHeight/2.5);
text("Information",displayWidth*.6, displayHeight/2.5);
text("Exhibition Calendar", displayWidth/36, displayHeight*.6);
text("The Arts at NIU", displayWidth*.55, displayHeight*.6);
if (AboutOver){
fill(homeButtonColor);
stroke(4);
fill(homeButtonHighlight);
}
else{
fill(homeButtonColor);
}
textFont(arialBold, displayHeight*.08);
text("About", displayWidth/6, displayHeight/2.5);
}
/*//sets up scene for South Lobby scene
if (exhibit == ){
image(SouthLobby, displayWidth/2, displayHeight/2, displayWidth, displayHeight);
}
*/
} // void draw closing bracket
void update(float x, float y){
if(AboutOver(AboutButtonX, AboutButtonY, AboutButtonWidth, AboutButtonHeight)){
AboutOver = true;
}
}
void mousePressed(){
if (AboutOver) {
exhibit = 1;
}
else{
exhibit = 0;
}
}
//setup for about button highlight and click boolean
boolean AboutOver (float x, float y, float width, float height){
if(mouseX >=x && mouseX <= x + width &&
mouseY >= y && mouseY <= y + height){
return true;
} else {
return false;
}
}
1