【问题标题】:Loading scene plugins in Phaser 3在 Phaser 3 中加载场景插件
【发布时间】:2019-03-04 07:20:34
【问题描述】:

Phaser 的新手。我正在使用 Phaser 3.16.2 和来自https://github.com/rexrainbow/phaser3-rex-notes 的插件。

当我在第一个场景(Docs)的 preload() 方法中加载插件,然后在 create() 方法中的同一场景中使用它时,它可以正常工作。但是,如果我更改场景(到 Docs2)并尝试使用其中的插件,则会收到错误消息:

TypeError: this.rexUI is undefined

我在控制台日志中看到插件在两个场景中都加载了。

class Docs extends Phaser.Scene {

constructor() {
    super({key: 'Docs'})
}

init(data) {
}

preload() {     
    console.log(this);
    this.load.scenePlugin({
        key: 'rexuiplugin',
        url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',
        sceneKey: 'rexUI'
    });
}

create() {
    this.backButton = new Button(this, 50, 50, 'btn-start', this.goDocs2, 'goDocs2');
    var itemInfoRect = this.rexUI.add.roundRectangle(96, 96, 50, 50, 0, COLOR_DARKEST);
}   

goDocs2() {
    this.scene.start('Docs2');
}
}


class Docs2 extends Phaser.Scene {

constructor() {
    super({key: 'Docs2'})
}

init() {

}

preload() {     
    console.log(this);
}

create() {
    var itemInfoRect = this.rexUI.add.roundRectangle(96, 96, 50, 50, 0, COLOR_LIGHT);
}

}

【问题讨论】:

    标签: javascript phaser-framework


    【解决方案1】:

    好的,这是一个开放的错误。有一个解决方法:

    https://github.com/rexrainbow/phaser3-rex-notes/issues/10

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      相关资源
      最近更新 更多