Is there a way to create a custom class hero that extends from SpriteWithDynamicBody
? I'm unable to do so because SpriteWithDynamicBody
is only defined as a type, and we can't extend from a type in Typescript.
I can only extend from Sprite
, but then some methods/properties are not available:
export class Hero extends Phaser.GameObjects.Sprite {
constructor(public scene: Phaser.Scene, x: number, y: number, texture: string, frame?: number) {
super(scene, x, y, texture, frame);
this.setVelocity(0); // => Error
}
}
Any suggestions on how I can extend SpriteWithDynamicBody
instead?