xxxxxxxxxx
let actionCount = 0;
function setup() {
createCanvas(400, 200);
textSize(18);
createSlider(1, 120, 60)
.changed(event => frameRate(Number(event.target.value)));
}
function draw() {
background('white');
if (frameCount % 120 === 0) {
performAction();
}
text(`frameRate = ${round(frameRate())}`, 10, 20);
text(`frameCount = ${frameCount}`, 10, 45);
text(`actionCount = ${actionCount}`, 10, 70);
}
function performAction() {
actionCount++;
background('red');
}