quiero accerder a la variable ctx la cual esta localizada en el constructor de mi juego y en la funcion bucle la cual accede a ella para limpiar el canvas me sale el error "main.js:191 Uncaught TypeError: Cannot read property 'clearRect' of undefined" codigo->
class JuegoSnake {
constructor() {
this.comidas = [];
this.canv = document.getElementById("canvas");
this.puntuacion = 0;
this.ctx = this.canv.getContext("2d");
this.scl = 40;
this.canv.width = window.innerWidth;
this.canv.height = Math.floor(window.innerHeight * 1);
this.serpiente = new snake();
this.comidas.push(new comida(this.scl));
}
draw() {
this.ctx.clearRect(0, 0, this.canv.width, this.canv.height);
drawFondo(this.ctx);
}
draw()
?