containers - 为什么我在 Phaser 中的游戏无法识别 Phaser.GameObjets.Container?
问题描述
嘿,我一直在尝试在画布中输入乐谱文本,但给了我这个错误:未捕获的类型错误:无法读取未定义的属性“容器”。
这是代码:
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 但我不知道为什么不识别容器类,任何人都可以帮助我吗?
解决方案
至少在您的示例代码中,您有一个错字。应该Phaser.GameObjects.Container
不是Phaser.GameObjets.Container
推荐阅读
- python - 从真值表 pandas 中提取数据
- vb.net - 解析 json 文件时出错
- sql-server - 使用 SQLCMD 批处理文件将参数传递给存储过程
- node.js - 异步操作后,MongoDB 中的文件链接数组为空
- python - 为什么按下某个键时我的精灵不移动?
- javascript - 您可以在新的浏览器选项卡中打开 pdf 而不从后端设置 Content-Disposition
- java - 如何在映射到 Spring 配置类中的列表的环境变量中转义逗号
- reactjs - 如何将反应测试库类匹配器与 scss 模块一起使用?
- laravel - 如何在 uppy.io 库中预填充/预加载图像
- ios - 如何更新用户资料