xxxxxxxxxx
33
let score;
// nesessary for the web editor to register iOS touch event
document.addEventListener("touchstart", () => {return});
function setup() {
createCanvas(400, 400);
score = getItem("localStorage-Test_score");
if (score == null) {
score = 0;
}
}
function draw() {
background(220);
textSize(50);
textAlign(CENTER, CENTER);
text(score, width / 2, height / 2);
}
function mousePressed() {
addOne();
}
function addOne() {
score += 1;
storeItem("localStorage-Test_score", score);
}
function touchStarted() {
mousePressed();
}