así que he estado tratando de hacer un entrenador de puntería con javascript p5, pero cuando intento cargar una imagen como un objetivo que se puede disparar al azar, parece que no me permite hacer clic en la imagen. Realmente no entiendo por qué, ya que soy nuevo en la codificación. también el hacer clic en la elipse normal no funciona. pero ahora mismo eso no es lo que me preocupa.
error: TypeError: img2 no es una función en draw (/script.js:82:5) en p5._main.default.redraw ( https://cdn.jsdelivr.net/npm/p5@1.3.1/lib/ p5.js:70718:27 ) en _draw ( https://cdn.jsdelivr.net/npm/p5@1.3.1/lib/p5.js:63058:25 )
let MENU = 0; let img; let img2; // ------------------------------------------- var life = 3; var score = 0; var shootFail = 0; var x, y; const radius = 20; function preload() { img = loadImage('GAME_logo.png') img2 = loadImage('durtburd.png')// ----------------------------------- } function setup() { createCanvas(800, 600); } function mousePressed() { // Check if mouse is inside the circle var d = dist(mouseX, mouseY, x, y); if (d < radius) { newCircle(); score++; } console.log("text", mousePressed) } function newCircle() { x = random(750); y = random(550); } setInterval(newCircle, 1000); function draw() { cursor('test2.cur'); background(225); // maakt start reflex knop fill('darkgray'); rect(50, 50, 200, 75); // maakt instructions knop fill('darkgray'); rect(50, 200, 200, 75); // maakt start tracking knop fill('darkgray'); rect(50, 350, 200, 75); //maakt de teksten aan textSize(25); fill('white'); text('START', 60, 90); //start text text('REFLEX', 60, 110); // reflex text textSize(24); text('INSTRUCTIONS', 60, 250); // instuctions text textSize(25); text('START', 60, 390); // start text text('TRACKING', 60, 410); // tracking text scale(0.9) image(img, 320, 50, 530, 520) // loads the logo if (MENU == 1) { // START GAME noStroke(); background(35, 39, 42); fill('white'); textSize(20); text('Press escape to return to MENU', 500, 30); textSize(60); fill('red'); text('♥'.repeat(life), 400, 300); fill('white'); textSize(30); text("Score: " + score, width/2, height/2 + 40); text("Misses: " + shootFail, width/2, height/2 + 65); //ellipse(x, y, radius*2, radius*2); image(img2,x, y); //dont know how to implement this------------------------------------ if (keyIsDown(27)) { MENU = 0; }