Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Pause draw()

$
0
0

I know that is not a good practice using delay() but i'm trying different ways to pause a sketch and I can't.

I'm trying to run a simple program, with minim, when line in reaches X volume, a trigger is shot, and the program shows and image for two seconds. Then, the program continues listening to. I load the image outside the bounds of the canvas (x and y = 3000) and when the volume reaches 100, x and y is changed to 0 0, so, the image appears in the screen.

For now all works but the delay. How could I make the program pause for two seconds while is showing the image? I can make the delay when I want, but the image appears AFTER it, not before.

Thanks!

This is my code: ``import ddf.minim.*;

Minim minim;
AudioInput in;
PImage img;
PFont font;

float maxValue;
float minValue;
int frameValue;
  int posX =3000;
  int posY = 3000;

void setup()
{
  size(800, 600, P3D);
 img = loadImage("/Users/pablo/Downloads/vamo.jpg");
frameValue=200;
  minim = new Minim(this);
  minim.debugOn();
  // use the getLineIn method of the Minim object to get an AudioInput
  in = minim.getLineIn(Minim.STEREO, 512);
  font = createFont ("Arial", 60);

   posX =3000;
   posY = 3000;
}

void draw()
{

  background(0);
  stroke(255);
  image(img, posX, posY);
  //actual
  text("Actual: "+in.right.level()*100, 10, height/2);

   if(in.right.level()*100>10){   //if the volume reaches 10
     println("im in");
      posX=30;
      posY=30;
      //delay(3000);
      //frameRate(10);
  }else{
      posX=3000;
      posY=3000;
  }

}

Viewing all articles
Browse latest Browse all 2896

Trending Articles