我说的是voxel.js库:http://voxeljs.com/
我正在尝试创建第一款游戏的步骤:
我只是按照以下步骤操作:
“一旦安装了node.js,就可以在项目目录中安装基本的voxel.js npm包,然后安装基本的纹理包。在项目目录中创建一个名为package.json的文件,并将其内容提供给它:”
{
"name": "mygamename",
"version": "0.0.1",
"dependencies": {
"voxel-hello-world": "0.6.0"
}
}
“现在您可以告诉节点安装依赖项:”
$ npm install
“下一步,创建mygame.js
并将以下代码放入其中:”
var createGame = require('voxel-hello-world')
var game = createGame()
“然后使用browserify构建游戏:”
$ npm install browserify -g
$ browserify mygame.js -o builtgame.js
“将builtgame.js加载到网页中:”
<!doctype html>
<html>
<body>
<script src="builtgame.js"></script>
</body>
</html>
错误:
builtgame.js:49790 Uncaught TypeError: Cannot read property 'appendChild' of null
at Game.addStats (builtgame.js:49790)
at Game.initializeRendering (builtgame.js:50033)
at new Game (builtgame.js:49481)
at Game (builtgame.js:49399)
at module.exports (builtgame.js:50538)
at Object.31.voxel-hello-world (builtgame.js:6180)
at o (builtgame.js:1)
at r (builtgame.js:1)
at builtgame.js:1
如何解决这种情况并成功执行appendChild?