Hide Image After keyPressed

edited March 2015 in How To...

My images are displayed and I am able to cycle through them. But what I am trying to accomplish is to not have the previous image remain after the key is pressed. This is the closest example I can find, and so far I understand that something needs to be done with the boolean = true;. I do not know how to incorporate this, though.

PImage happiness;
PImage sorrow;
int x = 250;
int y = 250;

boolean showMask = true;

Happiness happy1;
Sorrow sorrow1;

void setup(){
   size(500,500);
   smooth();
   happiness = loadImage ("happiness0.png");
   sorrow = loadImage ("sorrow1.png");

   createMask();
}

//This is where my problem is 
    void draw (){
      if (keyCode == RIGHT) {
        sorrow1.display();
        sorrow1.godname();
      } else {  
        happy1.display();
        happy1.godname();
      } 
    }

void createMask() {
  happy1 = new Happiness (happiness, x, y);
  sorrow1 = new Sorrow (sorrow, x , y);      
}
Tagged:

Answers

  • Answer ✓

    No worries. It fixed itself... don't know how it happened. If anyone else is having trouble with this, the link above can give you some sort of idea.

Sign In or Register to comment.