Currently, I am facing a challenge while trying to incorporate inheritance into a game I am developing using typescript (pixi.js). The issue arises when I encounter this error. In my code, I have a class named Dog with the following implementation:
export class Dog extends Enemy {
//private game: Game;
//private speed: number = 0;
constructor(texture: PIXI.Texture, game: Game) {
super(texture);
this.game = game;
}
Additionally, I have another class called Enemy, which serves as the superclass that Dog extends from. Here is how Enemy is structured:
export class Enemy extends PIXI.Sprite {
public game: Game;
public speed: number = 0;
constructor(texture: PIXI.Texture, game: Game) {
super(texture);
this.game = game;
}
However, within my dog.ts file, I encounter an error specifically under the line super(texture); in my code stating: "Expected 2 arguments, but got 1.ts(2554) enemy.ts(8, 38): An argument for 'game' was not provided."
This message has left me confused as I have provided an argument for the game parameter in enemy.ts and I am also extending from Pixi.sprite.
Update: Upon modifying the super in enemy.ts to super(texture, game), a new error surfaces reading: "Expected 0-1 arguments, but got 2.ts(2554)". This suggests that I can only pass one argument in the super function, hence highlighting the limitation of resolving the issue this way.
Consequently, upon further investigation, I realized that I had mistakenly modified the incorrect file initially.