FrameCount animation

edited January 2014 in How To...

Hi,

I would like a frame count animation with one image but different timing based on the frameCount(i guess that a timer would also work here). I made the image to blink however i would also like the image to stop after 4 seconds and then to continue blinking after 5 seconds. This is what i got so far.

 int blink = frameCount%40;

   if(blink> 10) {
      image(blinkImg, 1052, 403);
    }

Not much :/.

I also have a question concerning arrays. I have loaded multiple images with an array and they need to blink as well, stop after some time and then continue. Do you increase the elements by one in the array like this? I saw an example here http://www.learningprocessing.com/exercises/chapter-9/exercise-9-6/ but it's not working for me.

for(int i=0; i < img.length-1; i++) {
    img[i] += img[i+1]; // this is not working
    image(img[i], 120, 200);
  } 
}

Thanks

Answers

  • Something I still don't get it: Are the PImage pics supposed to be displayed at once or 1 at a time? :-??

  • edited January 2014

    They are two separate questions. For the second they should be displayed one at a time, in the same time interval, then stop for some seconds and then continue again.

  • edited January 2014

    Another thing: By blinking you meant rotating the displaying of the PImage[]? ^#(^

  • Yes rotating at a given time interval, stopping for awhile and looping again.

  • edited January 2014 Answer ✓

    Dunno if I got you right but... here it is my blueprint of it: (~~)

    /** 
     * Blink Pause Framecount (v1.01)
     * by GoToLoop (2014/Jan)
     *
     * forum.processing.org/two/discussion/2557/framecount-animation
     */
    
    static final color[] colors = {
      #FF0000, #008000, #0000FF, #FFFF00, #00FFFF
    };
    
    static final FakeImage[] imgs = new FakeImage[colors.length];
    
    static final int FPS = 60;
    static final int BLINKT = 4*FPS, STOPT = 5*FPS;
    static final int TOTALT = BLINKT + STOPT;
    static final int FREQ = FPS>>3;
    
    static int idx, num = imgs.length;
    
    void setup() {
      size(600, 400);
      frameRate(FPS);
      smooth(4);
      rectMode(CORNER);
    
      for ( int i = 0; i != num; imgs[i] = new FakeImage(colors[i++]) );
    }
    
    void draw() {
      clear();
    
      final int fc = frameCount % TOTALT;
    
      frame.setTitle("Second #" + fc/FPS);
    
      if (fc > BLINKT)  return;
      if (frameCount % FREQ == 0)  idx = (idx + 1) % num;
    
      imgs[idx].display();
    }
    
    class FakeImage {
      final int x = width>>2, y = height>>2;
      final int w = width>>1, h = height>>1;
      final color c;
    
      FakeImage(color cc) {
        c = cc;
      }
    
      void display() {
        fill(c);
        rect(x, y, w, h);
      }
    }
    
  • Enlightenment :D. That was a great example thank you so much :).

Sign In or Register to comment.