Loading...
Logo
Processing Forum
Huh. Seems like that sweet answer disappeared. Anyway, if you want to display a loading percentage that goes up 5% at a time, and takes between 5 and 10 seconds, you can do this:
Copy code

  1. int totalTime;
  2. PFont myFont = createFont( "Ariel", 12 );

  3. void setup() {
  4.   size(200,200);
  5.   fill(0);
  6.   totalTime = 5 + int(random(6));
  7.   textFont( myFont );
  8. }

  9. void draw() {
  10.   background(255);
  11.   text( str(totalTime) + " seconds", 20, 20 );
  12.   text( str(5 * int(map(constrain(millis(),0,1000*totalTime), 0, 1000 * totalTime, 0, 20)) ) + "%", width/2-15, height/2+5);
  13. }

Replies(1)

i'm very sorry i don't know how to use these forums properly :( Thanks so much for your help!