Loading...
Logo
Processing Forum
Hey everyone! (i'm a noob),
I'm struggling to figure out what would i need to do in order to make my program start with a white background and once mouseClicked once the white background disappears (and my program actually begins).

Thanks for your time!

Replies(2)

Processing will tell you when the mouse has been pressed by calling mousePressed.  You can do something in that function to record that a mouse pressed has occurred and decide what to draw based on that variable.

Copy code
  1. boolean hasMouseBeenPressed = false;

  2. void setup() {
  3. }

  4. void draw() {
  5.   if (hasMouseBeenPressed) {
  6.     // do the normal program stuff
  7.     rect(10, 10, 50, 50);
  8.   } else {
  9.     background(255);
  10.   }
  11. }

  12. void mousePressed() {
  13.   hasMouseBeenPressed = true;
  14. }
thanks so much Jonny! 
I used this method and slightly changes it as i have too many things to put them all in the if statement so i just said 

if (!hasMouseBeenPressed) {
background(255)
}

thanks for helping me understand the concept :)