'text' problems with strings
in
Programming Questions
•
3 years ago
hey! i quite new to processing, so please excuse my non existing knowledge :)
i would like to build a random character animation, which generates a random number of lines and a random number of letters per line. but i don't want them to show up all at once, after 'void draw' has finished, but just one at a time. so one character after another should show up until the "drawing" is over. but my code just shows one character at the beginning, then, after the 'delay' all the other characters...
i know, it sounds confusing... but can you help me?
this is my code: -----
import guru.ttslib.*;
TTS tts; // call text to speech class
PFont f;
String letters = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Ä Ü Ö 1 2 3 4 5 6 7 8 9 0 + - / * ! ? =";
String[] words = split(letters, ' ');
void setup() {
size(1000, 500);
// background(255);
f = loadFont("andale.vlw");
}
void draw() {
background(255);
fill(0);
textFont(f, 20);
//tts = new TTS(); //call speak object
int counter3 =(int) random (1,4); // call basic var
int ycoor = 50; // y axis für die FOR schleife
for (int textLine=0; textLine<counter3; textLine++) { //
int counter1 =(int) random (1,4);
int xcoor = 30;
for (int letter=0; letter<counter1; letter++) {
int counter2 =(int) random (1,4);
tts = new TTS(); //call speak object
tts.speak(words[counter2]); // speak letters -> this is fuctioning, but the text isn't
text(words[counter2], xcoor , ycoor ); // this is just working at the end, but not "one after another", which is strange..
xcoor += 30; // letter spacing
delay(500); // Stops the program for 250 milliseconds
}
ycoor += 40; // line break
}
noLoop();
}
1