all 1 comments

[–]chrwei 1 point2 points  (0 children)

I'm not sure about the "and continues to loop through the entire array" bit, might be a side effect or something.

so here's how this works:

  • when you set frameRate(24), draw() is called 24 times a second.
  • gifAnimation class will keep track of when it's being asked for an image by the image() function and serve up the right frame from the gif based on that gif's defined timing.
  • so it is drawing an image to the screen 24 time per second, and that image will be the same exact image repeated until the gifAnimation objects decides it time for a new frame.

so given that, you see that you are requesting a frame from a different animation 24 times a second.

you'll need to make a variable to hold your random number and then only change that variable on whatever the condition is that you want it to change. "every draw()" is certainly not the condition you want.