Loading...
Logo
Processing Forum
I get this error :

Warning controller with name Fademount allready exists. overwriting reference of existing controller.



it makes the sketch slower over time.

any idea on how to fix it ?

Thanx !

Copy code
  1. import controlP5.*;

  2. ControlP5 controlP5;

  3. int tamanoPunto = 2;
  4. int distance = 1; 
  5. float rate1 = 0.02;
  6. Fade myFade;
  7. float time =0;
  8. int FadeAmount = 60 ;
  9. void setup () 
  10. {
  11.   size ( 800, 400);
  12.   smooth();
  13.   background(#1D2124);
  14.   myFade = new Fade();
  15.   frameRate (25);
  16.   mouseX = 10;

  17.   // HERE !
  18.   controlP5 = new ControlP5(this);
  19.   controlP5.addSlider("distance", 0, 100, 0, width-(width/4), height/50, width/4-(width/40), 40).setId(1);   
  20.   controlP5.addSlider("tamanoPunto", 0, 100, 2, width-(width/4), height/50*(7), width/4-(width/40), 40).setId(2);   
  21.   controlP5.addSlider("rate1", 0.01, 0.1, 0.02, width-(width/4), height/50*(13), width/4-(width/40), 40).setId(3);
  22.  
  23. }
  24. //    

  25. void draw () {
  26.   float rate  ; 
  27.   myFade.display();

  28.   for ( float i = 0 ; i < width ; i ++   ) {
  29.     stroke (255);
  30.     strokeWeight(tamanoPunto);
  31.     point (i+=distance, height* noise(i/100, time));
  32.   }

  33.   rate = rate1 ;
  34.   time = time+rate;

  35. void keyPressed()
  36. {
  37.   if (key == 'w' ) {
  38.     distance+=1;
  39.   } 
  40.   if (key == 'q' ) {
  41.     distance-=1;
  42.   } 
  43.   if (key == 's' ) {
  44.     tamanoPunto+=1;
  45.   } 
  46.   if (key == 'a' ) {
  47.     tamanoPunto-=1;
  48.   }
  49. }

  50. class Fade 
  51. {
  52.   // global vars
  53.   int FadeAmount_ = FadeAmount;
  54.   // constructor
  55.   Fade ()
  56.   {
  57.   }
  58.   //  function 
  59.   void display () {
  60.  controlP5.addSlider("FadeAmount", 0, 250 , width-(width/4), height/50*(19), width/4-(width/40), 40).setId(4);
  61.     fill ( #1D2124, FadeAmount);
  62.     noStroke ();
  63.     rect (0, 0, width, height);
  64.   }
  65. }

Replies(3)

use the same name as the variable you want to change is probably the easiest way

  controlP5.addSlider("distance", 0, 100, 0, 100, 26, 200, 40).setId(4);  

Thanx Cedric, but i have a new problem.



I get the error :

Warning controller with name FadeAmount allready exists. overwriting reference of existing controller.


I guess the problem is in the class Fade, but i dont know where is the problem.

Any ideas ?

The new code is above in my fisrt post.
Fixed it.


I was in the wrong place.


Fixed code: 

Copy code
  1. import controlP5.*;

  2. ControlP5 controlP5;

  3. int tamanoPunto = 2;
  4. int distance = 1; 
  5. float rate1 = 0.02;
  6. Fade myFade;
  7. float time =0;
  8. int FadeAmount = 60 ;
  9. void setup () 
  10. {
  11.   size ( 800, 400);
  12.   smooth();
  13.   background(#1D2124);
  14.   myFade = new Fade();
  15.   frameRate (25);
  16.   mouseX = 10;

  17.   // HERE !
  18.   controlP5 = new ControlP5(this);
  19.   controlP5.addSlider("distance", 0, 100, 0, width-(width/3), height/50, width/4-(width/40), 40).setId(1);   
  20.   controlP5.addSlider("tamanoPunto", 0, 100, 2, width-(width/3), height/50*(7), width/4-(width/40), 40).setId(2);   
  21.   controlP5.addSlider("rate1", 0.01, 0.1, 0.02, width-(width/3), height/50*(13), width/4-(width/40), 40).setId(3);
  22.  controlP5.addSlider("FadeAmount", 0, 250 , width-(width/3), height/50*(19), width/4-(width/40), 40).setId(4);
  23. }
  24. //    

  25. void draw () {
  26.   float rate  ; 
  27.   myFade.display();

  28.   for ( float i = 0 ; i < width ; i ++   ) {
  29.     stroke (255);
  30.     strokeWeight(tamanoPunto);
  31.     point (i+=distance, height* noise(i/100, time));
  32.   }

  33.   rate = rate1 ;
  34.   time = time+rate;

  35. void keyPressed()
  36. {
  37.   if (key == 'w' ) {
  38.     distance+=1;
  39.   } 
  40.   if (key == 'q' ) {
  41.     distance-=1;
  42.   } 
  43.   if (key == 's' ) {
  44.     tamanoPunto+=1;
  45.   } 
  46.   if (key == 'a' ) {
  47.     tamanoPunto-=1;
  48.   }
  49. }

  50. class Fade 
  51. {
  52.   // global vars
  53.   int FadeAmount_ = FadeAmount;
  54.   // constructor
  55.   Fade ()
  56.   {
  57.   }
  58.   //  function 
  59.   void display () {
  60.  
  61.     fill ( #1D2124, FadeAmount);
  62.     noStroke ();
  63.     rect (0, 0, width, height);
  64.   }
  65. }