Extending an extended class (ES5 vs ES6)

Hi, I’m a big noob when it comes to coding, so please excuse any stupid mistakes.

I’m trying to follow the tutorial for turn based rpg to learn phaser.

After a long time I figured that it’s written in ES5 so I thougt that I change it to ES6 as an excercise.

Now (of course) I get errors when running the code. I have no idea what this error means but I assume it’s from extending classes incorrectly.

The error that I get is:

Uncaught TypeError: Cannot read property ‘queueDepthSort’ of undefined
at HeroesMenu.initialize [as constructor].

I try to extend this menu class…

class Menu extends Phaser.GameObjects.Container {
constructor(x, y, scene, heroes) {
    super(x, y, scene, heroes);
    this.menuItems = [];
    this.menuItemIndex = 0;
    this.heroes = heroes;
    this.x = x;
    this.y = y;
}
   }

this is how I extend the Menu Class

class HeroesMenu extends Menu {
constructor(x, y, scene) {
    super(x, y, scene);
  }

}

I call the menu as such:

    this.menu = this.add.container();
    this.heroesMenu = new HeroesMenu(195,153,this);
    this.currentMenu = this.actionsMenu;
    this.menus.add(this.heroesMenu);

Are there any obvious mistakes?

In case I missed anything, here is whole code.


.

The super() arguments for Container are wrong. They should be

super(scene, x, y, heroes);
1 Like

omg, it works! thank you @samme <3

I like the new docs system!