画像をクリックした後、フェイザー3シーンを変更することはできません

Mahma仁王門:

私は、クリックイベントを設定することにより、フェイザー3に別のシーンから移動しようとしていますが、呼び出しに問題がありthis.scene.start('entryLevel');、私は私がいることを取得した画像をクリックすると、:

this.scene.start 関数ではありません

どのように私はこの問題を解決することができ、なぜ、私は把握することはできませんか?ここに私のコードは次のとおりです。

class MainMenu extends Phaser.Scene {
    constructor() {
        super('bootGame')
    }

    preload() {
        this.load.image('menuBackground', 'assets/world/menubackground.png');
        this.load.image('play_button', 'assets/world/play_button.png');
        this.load.audio('menu_music', 'assets/music/menu_music.mp3');
    }

    onObjectClicked() {
        this.scene.start('entryLevel');
    }

    create() {
        this.add.image(400, 300, 'menuBackground');
        var playButton = this.add.image(this.game.renderer.width / 2, this.game.renderer.height / 3, 'play_button').setDepth(1);
        playButton.setInteractive();
        this.input.on('gameobjectdown', this.onObjectClicked);

        this.sound.play('menu_music', {
            loop: true
        });
    }
}
norbitrial:

私は、これはスコープ問題になることができると思います。

あなたのために、次の作品ならば試してみてください。

const self = this;
this.input.on('gameobjectdown', function () {
   self.scene.start('entryLevel');
});

私はそれが役に立てば幸い!

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=281234&siteId=1