In p5 I have a code with mouseClicked() function.
I want this function to be called only when the canvas is clicked.
Any idea ?
In p5 I have a code with mouseClicked() function.
I want this function to be called only when the canvas is clicked.
Any idea ?
I found the answer. When creating the canvas, link it to a function like this:
function setup() {
var canvas = createCanvas(width, height);
canvas.mouseClicked(my_function);
...
}
function my_function(){
...
}