【发布时间】: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