Не работает отображение картинки на canvas(javascript)
Делаю игру про шарики с использованием классов.
Код:
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
ctx.fillText("Загрузка...", canvas.width / 2, canvas.height / 2);
class Ballon{
constructor(src, x, y){
this.img = new Image();
this.img.onload = this.draw;
this.img.src = src;
this.x = x;
this.y = y;
}
draw(){
ctx.drawImage(this.img, this.x, this.y);
}
horizon_move(bias){
ctx.clearRect(this.x, this.y, this.x + this.img.width, this.y + this.img.height);
this.x += bias;
this.draw();
}
}
ballon = new Ballon("images//balloon.png", 20, 20);
Строчка this.image.onload = this.draw должна при загрузке изображения запустить функцию draw.
Но ничего не работает и мне вылазит вот эта ошибка:
Помогите пожалуйста решить проблему. 2 дня думаю и ничего не получается