This video covers the setInterval() function in JavaScript in the context of p5.js. setInterval() allows you to execute a given function every N milliseconds.

source

7 Comments

  1. This video is amazing! Daniel, If you've got a spare moment i'd love your help! I've got my simulation running by clicking on a button which sets off setInterval. When I click the button again it runs two simulations which makes canvas freak out. How can I clear the first simulation with the button then make the next simulation run over it? Thank in advance man!

  2. Hi Daniel, could you explain how the timer stops when you click the button again. I see your using an if else statement but how does it know to stop the timer? example) if ( !interval ){ interval = setInterval(); } else { clearInterval ( interval ); interval = false; }

Leave A Reply

Please enter your comment!
Please enter your name here