首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError: Crafty.scene不是函数

TypeError: Crafty.scene不是函数
EN

Stack Overflow用户
提问于 2018-12-18 11:10:36
回答 1查看 69关注 0票数 2

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

代码语言:javascript
复制
Uncaught TypeError: Crafty.scene is not a function
at Level1.js:4

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

代码语言:javascript
复制
<!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:

代码语言:javascript
复制
//Relevant code:
Crafty.scene('main', function() {
Crafty.init(500,500, document.getElementById('game'));
// rest of Crafty.scene...
}
Crafty.scene('main') 
EN

回答 1

Stack Overflow用户

发布于 2019-01-17 18:38:30

修正了电子论坛:显然,如果你需要一个模块在文件中,电子将不会在node_modules中寻找。https://discuss.atom.io/t/solved-typeerror-crafty-scene-is-not-a-function/61273

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53825875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档