Typescript 移相器3可点击的雪碧罐';不要开始场景

Typescript 移相器3可点击的雪碧罐';不要开始场景,typescript,phaser-framework,Typescript,Phaser Framework,我已经用typescript在Phaser3中创建了一个可点击的精灵。 我想在单击精灵时更改场景: export class BMO extends Phaser.GameObjects.Sprite { constructor(scene) { super(scene, 100,150, "bmo") this.scene.add.existing(this) this.setInteractive() this.on

我已经用typescript在Phaser3中创建了一个可点击的精灵。 我想在单击精灵时更改场景:

export class BMO extends Phaser.GameObjects.Sprite {

    constructor(scene) {
        super(scene, 100,150, "bmo")
        this.scene.add.existing(this)
        this.setInteractive()

        this.on('pointerdown', function (pointer) {
            this.scene.start('GameOver');
        }, this);
    }
}
在跑步游戏中单击精灵时,我得到:

this.scene.start不是函数

完全相同的代码在场景中而不是在精灵中工作:

export class GameScene extends Phaser.Scene {

    constructor() {
        super({key: "GameScene"})
    }

    create(): void {
        this.input.once('pointerdown', function (pointer) {
            this.scene.start('GameOver');
        }, this);
    }
}

如何从Phaser 3中的可单击精灵更改场景?

您应该像在第二个示例中一样,在
场景的
对象上调用
启动
方法

this.scene.scene.start('GameOver');

scene
对象上的
scene
属性指的是
ScenePlugin
,请查看感谢此功能。我觉得这些文件有些不可读。出于某些原因,IntelliSense在精灵中的
this.on('pointer down')
处理程序中不适用于我,因此我无法看到该场景具有另一个场景属性。我同意,文档需要一些额外的工作。但是,开发日志保存了我几次-强烈建议()