What happened to delay

uwt

My head just hurts. If you do this it doesn't work right it just stuck until all letters are displayed and if you remove "while" it still doesn't work also x=1; is done so to test if in second draw re-run it works. You can actually fix this if you like moving entire app to side cuz when mouse holding app touches side of screen app works for that moment and it can't be still.

Answers

  • Answer ✓

    all drawing operations done within draw() are cumulated, and only the end result is displayed when draw() exits. So, actually, you paint each image in sequence, one over the others, then you display the end result, the last image.

  • edited August 2017
    if(x==1)
    text("H",0,32);
    if(x==2)
    text("e",32,32);
    if(x==3)
    text("l",64,32);
    if(x==4)
    text("l",96,32);
    if(x==5)
    text("o",128,32);
    if(x==6)
    text("!",160,32);
     x=x+1;
      delay(1000);
    

    Moral of the story don't try shortcuts just go longer way (>_<). Also thanks mate.

  • Delay is not recommended anyway

    Instead build a timer and increase x when the is met (every second)

  • edited August 2017

    @StereoFrog -- Or use the built-in frameRate() to set the draw speed and the built-in frameCount as the timer.

    You could use an array of chars or a String to do this:

    char[] cs = {'H', 'e', 'l', 'l', 'o', '!'};
    String s = "Hello!";
    
    void setup() {
      size(300, 100);
      textSize(32);
      frameRate(1); // draw ~1/sec
    }
    void draw() {
      background(0);
    
      // draw characters
      for (int i=(frameCount-1)%cs.length; i>=0; i--) {
        text(cs[i], 32*i, 32);
      }
    
      // draw string
      text(s.substring(0, frameCount%(s.length()+1)), 0, 96);
    }
    
  • @jeremydouglass @Chrisir Thanks those are great answers they really helped me =D>

Sign In or Register to comment.