Triborg-333
@Triborg-333

Cannot read property 'x' of undefined Canvas?

Почему не видит внутриconstructor this.myPos?

class Body {
		constructor(x, y){
			this.x = x;
			this.y = y;
			this.size = {width:19, height:19};
			this.myPos = {x : canvas.width / 2 - this.size.width, y : canvas.height / 2 - this.size.height};
		}
	}


	App.prototype.draw = function(){
		ctx.clearRect(0, 0, canvas.width, canvas.height);

		ctx.fillRect(this.myPos.x, this.myPos.y, 50, 50);
	}


  • Вопрос задан
  • 57 просмотров
Решения вопроса 1
RAX7
@RAX7
ctx.fillRect(this.body.myPos.x, this.body.myPos.y, 50, 50);
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы