We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm looking to raise a value while the mouse is held down. What is the function I'm looking for? My code only raises the value once for each click.
var i = 0;
function setup() {
createCanvas(200, 200);
background(222);
}
function draw() {
noStroke();
fill(55);
rect(20,20, 20,i+1);
}
function mousePressed() {
i++
print(i);
}
Answers
use mousePressed but the variable of the same name
in draw(): if(mousePressed) { .... }
https://p5js.org/reference/#/p5/mouseIsPressed