【问题标题】:Why does my game in Phaser doesn't recognizes Phaser.GameObjets.Container?为什么我在 Phaser 中的游戏无法识别 Phaser.GameObjets.Container?
【发布时间】:2021-02-08 15:25:13
【问题描述】:

嘿,我一直在尝试在画布中输入乐谱文本,但给了我这个错误:Uncaught TypeError: Cannot read property 'Container' of undefined。

代码如下:

class ScoreBox extends Phaser.GameObjets.Container{
    constructor (config){
    //invoke constructor of extended class
        super (config.scene);
    //get scene from parameter and set scene atribute
        this.scene = config.scene;
    //add a text box to the scene
        this.text = this.scene.add.text ( 0, 0, "SCORE: 0");
    //set text origin
        this.text.setOrigin (0.5, 0.5);
    //add the text to the container
        this.add (this.text);
    //add the container to the scene
        this.scene.add.existing (this);
    //Enable score update through emitter
        emitter.on (messageConstants.SCORE_UPDATED, this.scoreUpdated);
    }
    scoreUpdated (){
        this.text.setText ("SCORE: " + model.score);
    }
    
}

我正在将它连接到 html,但我不知道为什么无法识别容器类,任何人都可以帮助我吗?

【问题讨论】:

    标签: containers phaser-framework


    【解决方案1】:

    至少在您的示例代码中您有一个错字。应该是Phaser.GameObjects.Container 而不是Phaser.GameObjets.Container

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2021-09-28
      • 2020-06-26
      • 1970-01-01
      相关资源
      最近更新 更多