html - 移相器游戏不是工人阶级扩展问题
问题描述
我正在为一个项目设计,它对我的场景说这个,它只是一个白色的空白屏幕
当我检查调试时,我得到了这个:
Uncaught TypeError: Class extends value undefined is not a constructor or null
这是我的索引文件
<!doctype html>
<html lang="en">
<head>
<title>save the mahanadi river, an energy project</title>
<!--libs-->
<script src="//cdn.jsdelivr.net/npm/phaser@3.24.1/dist/phaser.js"></script>
<!--project-->
<script type = "text/javascript" src = ".js/game.js"></script>
<!--scenes-->
<script type = "text/javascript" src = "scenes/boot.js"></script>
<script type = "text/javascript" src = "scenes/menu.js"></script>
</head>
<body>
<H1>hello for now</H1>
</body>
</html>
和我的场景问题代码
class Boot extends Phaser.scene {
constructor() {
super("Boot")
};
preload (){
};
create (){
this.add.text(20, 20, "welcome!")
};
update (){
};
};
这是我的game.js
window.onload = function(){
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: 'arcade',
arcade: {
gravity: { y: 300 },
debug: false
}
},
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
}
ok thanks photon storm but i still have bugs
my game.js
window.onload = function(){
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
Scenes: [Boot,Menu],
Scenes.push(Boot),
Scenes.push(Menu),
physics: {
default: 'arcade',
arcade: {
gravity: { y: 300 },
debug: false
}
},
};
var game = new Phaser.Game(config);
}
它在 phaser.push 上给出的概率
解决方案
如果你打算为你的场景使用一个类,那么你需要改变你的游戏配置来反映这一点。目前它仍在使用旧的 3-function 方法,但您需要告诉它您现在使用的是 Scene 类:
scene: [ Boot ]
“引导”是您的引导场景。添加更多场景?将它们附加到此数组。列表中的第一个将自动启动。
推荐阅读
- azure - Argo 事件:通过 Azure 子网上的 K8s 负载均衡器公开 Webhook
- python - 我们如何使用 scappy 生成应用层数据包,即 HTTP、FTP、TELNET、DNS 等
- r - 尝试渲染(ggplot)密度图时,无法解决 R Shiny 错误,“'x' 和 'units' 的长度必须 > 0”
- java - 在 CommandLineRunner bean 打印实体时获取“无法初始化代理 - 无会话”,但使用邮递员在控制器类中工作正常
- apache-flink - 我可以使用 Flink 的文件系统连接器作为查找表吗?
- javascript - 如何在 Razor 视图中将 Form 用于 foreach 循环
- php - AMP Parallel:无法打开流:ClassLoader.php 中打开的文件过多
- azure - 如何制作包含两条线(来自两个 Kusto 查询)的 Application Insights 仪表板指标图表?
- oop - 如何在 Pharo 中创建方法
- r - R Shiny 使用 selectInput 忽略占位符标签/值过滤