0

Мне нужно создать объект Orc

class Orc extends new Entity(){
constructor(){
    super();

    this.lifetime = 100;
    this.move_x = 0;
    this.move_y = -1;
    this.speed = 1;
}}

Который наследуется от класса Entity

class Entity{
constructor(){
   this.pos_x = 0;
   this.pos_y = 0;
   this.size_x = 0;
   this.size_y = 0;
}}

Когда я пытаюсь это сделать

let obj = null;
                obj = new Orc();

У меня вылетает исключение: Class extends value # < Entity > is not a constructor or null

Кто-нибудь помогите разобраться с этой проблемой

1 ответ 1

1

Оператор new и скобочки лишние. Нужно так:

class Orc extends Entity {
constructor(){
    super();

    this.lifetime = 100;
    this.move_x = 0;
    this.move_y = -1;
    this.speed = 1;
}}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.