Hello all,
So I'm trying to figure out how to make it so in my program below the image I'm using for my start button dissapears after it is clicked. I want the user to click the button and everything that is on the screen gets cleared so that I can then draw the new stuff on the screen that I want.
I've tried using setVisible() and isVisible() but I don't know if that works with PImage or only PShape. Also I don't even know if I used it correctly.
Below is my code, any help would be appreciated.
Code:PFont myFont;
void setup()
{
size(500,500);
background(0,0,0);
smooth();
myFont = createFont("Verdana", 24);
textFont(myFont);
}
void draw()
{
drawIntro();
startButton();
}
void startButton()
{
//load startButton image
PImage start;
start = loadImage("START.jpg");
start.setVisible(true);
image(start, 180, 360);
//check if button is hovered over
if(mouseX > 180 && mouseY > 360 && mouseX < 324 && mouseY < 432)
{
//check if button is pressed
if (mousePressed == true)
{
start = loadImage("START2.jpg");
start.setVisible(false);
image(start,180,360);
if(start.isVisible() == false)
{
background(0,0,0);
}
}
}
}
void drawIntro()
{
noStroke();
fill(0,255,0);
text("Processing's Box of Wonders!", 75,100);
}