9.10: Reset a Sketch with Button Click – p5.js Tutorial

[ad_1]
This video looks at how to “reset” a p5 sketch on the click of a button. The example uses the p5.dom library and createButton() / mousePressed() functions.

code:

Contact:

All JavaScript/p5.js videos:

Help us caption & translate this video!


Posted

in

by

Tags:

Comments

7 responses to “9.10: Reset a Sketch with Button Click – p5.js Tutorial”

  1. Kumar Gajmer Avatar

    How to completely remove a button from the sketch?

  2. Adrian Pardo Avatar

    Hello, How do I give my button an id?

  3. RocksDa RS Avatar

    idk why you cant just call setup()

    what i do is:
    clear();
    setup();

    this way nothing gets layered or messed up, its like you refreshed the page

  4. Myth Sam Avatar

    hey ! i'm having troubles restarting your flappy bird code, it seems like it is only restarting the bird's position when i want to also reset the pipes, i'm kind of stuck, would love some help 🙂

  5. Gabi Avatar

    Can you add a link to the p5 flocking video?

  6. endofmysteries Avatar

    you know, I had been calling `setup()` in my `function windowResized()` [because the canvas size is windowWidth, windowHeight] and I thought everything was fine, but as you pointed out, I was just creating a new canvas every time! I'm glad you pointed this out!
    Daniel, if I wanted `windowResized()` to make the canvas size be `(windowWidth, windowHeight)` is there a way I could call setup() without it creating mutliple canvases? i.e. if I do `var canvas = createCanvas(windowWidth, windowHeight)` won't it just replace the variable `canvas` with a new one instead of creating ANOTHER canvas??

  7. Matías con tilde Avatar

    The button with the circle arrow icon called "Refresh" at the top of the window does just that.

Leave a Reply

Your email address will not be published. Required fields are marked *