gpt4 book ai didi

javascript - TypeError : Crafty. 场景不是函数

转载 作者:行者123 更新时间:2023-11-30 06:19:54 25 4
gpt4 key购买 nike

我有一个小问题。我正在使用 CraftyJS 开发游戏,我需要使用 Electron 来运行它,但是 Electron 抛出了这个错误:

Uncaught TypeError: Crafty.scene is not a function
at Level1.js:4

为什么要这样做?这是相关代码 + 标记:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Overtime-game</title>
</head>
<body>
<div id="game"></div>
<script type='text/javascript' src='./node_modules/craftyjs/dist/crafty.js'></script>
<script src='./Level1.js'>
</script>
</body>
</html>

JS:

//Relevant code:
Crafty.scene('main', function() {
Crafty.init(500,500, document.getElementById('game'));
// rest of Crafty.scene...
}
Crafty.scene('main')

最佳答案

已在 ELECTRON 论坛上修复:显然,如果您需要文件中的模块,Electron 将不会在 node_modules 中查找。 https://discuss.atom.io/t/solved-typeerror-crafty-scene-is-not-a-function/61273

关于javascript - TypeError : Crafty. 场景不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53825875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com