how to clear or remove methods after draw when press button?

edited March 2016 in Library Questions

Hi all, I'm trying to clear or remove methods after draw when I press button. Help me please.

Tagged:

Answers

  • Could you show your code please?

    In general, stuff is drawn in draw()

    draw() Starts with background(0); e.g.

    Thus everything is drawn again and again 60 times per second

    So once your button is pressed set a var drawItem to false

    The stuff you want to dissapear have in a if clause

    if(drawItem) { // call function/ method here

    }

    Please show your code

  • We're not sure what you're trying to do. Could you post some simple code that demonstrates your problem?

  • hey, guys. This's my code.

    import vialab.SMT.*;
    
    void setup() {
      size(1300, 700, SMT.RENDERER);
      SMT.init(this, TouchSource.AUTOMATIC);
      SMT.setWarnUnimplemented(false);
      SMT.add(new ButtonZone("Button1", 10, 70, 180, 45, "Selected 1"));
      SMT.add(new ButtonZone("Button2", 10, 130, 180, 45, "Selected 2"));
      SMT.add(new ButtonZone("ButtonReset", 10, 310, 180, 45, "Reset"));
    }
    
    void draw() {
      background(255);
    }
    
    void drawCartoCy1(Zone CartoCy1) {
      fill(255, 0, 0);
      rect(100, 100, 200, 200);
    }
    
    void drawCartoCy2(Zone CartoCy2) {
      fill(0, 255, 0);
      rect(100, 100, 200, 200);
    }
    
    void drawCartoSph1() {
      fill(255,255,0);
      rect(0, 0, 500, 400);
    }
    
    void drawCartoSph2() {
      fill(255, 0, 255);
      rect(0, 0, 500, 300);
    }
    
    void pressButton1() {
      Zone Car1 = new Zone("CartoCy1", 250, 80, 500, 500);
      SMT.add(Car1);
      Zone Cy1 = new Zone("CartoCy2", 780, 80, 500, 500);
      SMT.add(Cy1);
    }
    
    void pressButton2() {
      Zone Car2 = new Zone("CartoSph1", 250, 80, 500, 500);
      SMT.add(Car2);
      Zone Sph1 = new Zone("CartoSph2", 780, 80, 500, 500);
      SMT.add(Sph1);
    }
    
    void pressButtonReset() {
    
    // ************* How to reset as begin ?? *************
    
    }
    
    void touchCartoCy1() {}
    void touchCartoCy2() {}
    void touchCartoSph1() {}
    void touchCartoSph2() {}
    void touchButton1() {}
    void touchButton2() {}
    void touchButtonReset() {}
    

    @Chrisir @TfGuy44

  • Answer ✓

    Ah, it's concerning the library...

    Did you look into the documentation?

    SMT. remove or disable or hide....

  • Thanks you. @Chrisir I will try it.

Sign In or Register to comment.