hello there,
this is my first processing project …
what i like to do is to:
1. load a text file wich contains words (one word per row) - this works for me
2. select one word by random and display it for a short amount of time on the canvas - this works for me too
3. repeat this process n-times - - works for me too
4. pause this process (stop the loop) and display the current word for about 2-5 seconds - works for me too
5. start the loop again - this works NOT for me
hope you get the idea.
i tried it with loop() and noLoop() to start and stop the word selection and displaying. this seems not work as
millis() (which i use for the timing) stops working as soon as the loop stops. is there any workaround?
or is it more efficient to use a while loop instead?
the code:
String words[];
int pauseInt = 5000;;
int waitInt = pauseInt + 2000;;
void setup() {
size(800, 450);
background(255);
frameRate(30);
smooth();
textFont(createFont("Helvetica",50));
fill(0);
textAlign(CENTER, CENTER);
words = loadStrings("text.txt");
loop();
}
void draw(){
int selString;
background(255);
selString = (int)random(words.length);
text(words[selString], 400, 200);
if( millis() > pauseInt){
noLoop();
pauseInt = millis() + 5000;
}else{
loop();
}
}
thanks for your help.
grettings,
johannes