Background doesn't overwrite controlp5 elements

edited May 2015 in Library Questions

It starts with Intro, so the function draws a title "game" and a cp5 textfield "player".

when the button next is pressed the GAMESTATUS changes to "gamestarted", this starts the next if statement. this one draws an ellipse. the title "game" gets overwritten by the background but the cp5 textfield doesn't.

any idea how the textfield can be overwritten by the background or deleted/hide. Or is there a better way to change a "window". hope you can help me.

 import controlP5.*;
 ControlP5 cp5;
 String GAMESTATUS = "Intro";

void setup()
{
    size(1920, 1080);
    cp5 = new ControlP5(this);
    cp5.addButton("next").setPosition(500, 500).setSize(400, 100);      
}
void draw()
{ 
      background(#FEF4E9);
      fill(#FF0000);

     if(GAMESTATUS.equals("Intro"))
     {
         textFont(createFont("Verdana", 50));
         text("game", 850,60);  

        cp5.addTextfield("player").setPosition(200, 200).setSize(200, 50);       
     }
     else if(GAMESTATUS.equals("gamestarted"))
     {
           ellipse(56, 46, 55, 55);
     }        
}
public void next()
{
    GAMESTATUS = "gamestarted";               
}
Tagged:
Sign In or Register to comment.