on-internet
← Community

How to wait in p5.js

Stack Overflow ·

I'm trying to create a program that does something, waits for a set amount of time does another thing, then waits again. However, what actually happens is the program waits at the beginning then does both things without any delay between them. var start, current function setup() { createCanvas(500, 550); } function draw() { background(220); print('a'); wait(500); print('b'); wait(500); } function wait(time) { start = millis() do { current = millis(); } while(current < start + time) }

Comments

Sign in or sign up to comment and upvote.

No comments yet.