我有个小问题。我正在使用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') 发布于 2019-01-17 18:38:30
修正了电子论坛:显然,如果你需要一个模块在文件中,电子将不会在node_modules中寻找。https://discuss.atom.io/t/solved-typeerror-crafty-scene-is-not-a-function/61273
https://stackoverflow.com/questions/53825875
复制相似问题