• Saturday , 4 April 2020

9.5: JavaScript setInterval() Function – p5.js Tutorial

Code Canyon



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.

https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval

All examples: https://github.com/shiffman/Video-Lesson-Materials
Solution to exercise mentioned:
https://github.com/shiffman/Video-Lesson-Materials/blob/master/code_p5.js/9.2b_p5.js_setInterval/sketch.js

Contact: https://twitter.com/shiffman

Next video: https://youtu.be/-jysK0nlz7A

All JavaScript/p5.js videos: https://www.youtube.com/user/shiffman/playlists?shelf_id=14&view=50&sort=dd

Help us caption & translate this video!

http://amara.org/v/Qbtb/

Original source

3d Ocean

Related Posts

9 Comments

  1. Attaullah Khan
    October 23, 2017 at 11:33

    hello very nice explanation, i have set xml api with ajax get method,and set interval function to get latest data every 15 second ,now my question is every thing working fine in window linux android ,,but when i load it on iphon it,s refresh the whole page after 15 second and i dont want that it,s should run on background,,so please help me what i need to do ,here is the link :http://liveodd.co.uk/home/Livescore

  2. Simran Shikha
    October 23, 2017 at 11:33

    hii wnat to make a banner there i want to call div on given time n this works in loop what i do

  3. CritZ
    October 23, 2017 at 11:33

    Hey Dan, think you can help me? I want to make for a program of mine (a bot for Discord) a constant update on what "game" it's playing. Most of the bots use the games to show how to use the bot by setting it to their help command. However, I made a little customizable part, and I want my bot to check, let's say, every second if it changed. I'm not sure how to make setInterval do that, do you know by accident? If you need the code, just reply and I'll paste it.

  4. Anis Ara
    October 23, 2017 at 11:33

    Hello, i have a chart, and i want to setinterval it without drawing chart every second? do you have a idea?

  5. 3d animation
    October 23, 2017 at 11:33

    Sir,Does setup( ) gets call automatically?

  6. Matthew James
    October 23, 2017 at 11:33

    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!

  7. Brett L
    October 23, 2017 at 11:33

    Super useful stuff! Thanks for posting.

  8. Baron
    October 23, 2017 at 11:33

    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; }

  9. Jurgis Ramanauskas
    October 23, 2017 at 11:33

    you forgot to put the solution in the description, sir :))

Leave A Comment

You must be logged in to post a comment.