c# - printing string char by char/timer -
i making text-based game, wanted make intro text printing slowly(char char difference of ~100ms) tried making loop loops through string , prints chars 1 one, need timer inbetween wasn't able achieve of google. need making timer or algorithm in order print strings slowly. code:
static void printslowly(string print) { foreach(char l in print) { console.write(l); //timer here } console.write("\n"); }
nasty, nasty cheap solution :
static void printslowly(string print) { foreach(char l in print) { console.write(l); thread.sleep(10); // sleep 10 milliseconds } console.write("\n"); }
since don't care performance, go this. keep in mind thread.sleep pretty wasteful
Comments
Post a Comment