Meteor 和 Phaser - 简单样本的错误
Meteor and Phaser - error with simple sample
我已经运行独立使用 Meteor 应用程序和 Phaser 应用程序,一切都很好。但是,当我尝试 运行 使用 Meteor 的 Phaser 游戏时,我遇到了错误。
所以,一个问题是是否有人 运行 与 Meteor 一起成功使用 Phaser。
另一个 question/issue 更具体。我 运行 以下内容:
- ubuntu14.04
- 流星 1.1.0.2
- Phaser v2.3.0
我的目录包含:
- app.js
- index.html
- phaser.js
app.js:
if (Meteor.isClient) {
Template.game.game = function(){
var game = new Phaser.Game(320,320, Phaser.AUTO, 'firstGame', { preload: preload, create: create, update:update });
}
function preload(){
}
function create(){
}
function update(){
}
}
if (Meteor.isServer) {
};
}
index.html:
<body>
{{> game}}
</body>
<template name="game">
{{game}}
</template>
我运行流星时的错误是:
cmt@ubuntu:~/projects/myMeteorProjects/issueReplication1$ meteor
[[[[[ ~/projects/myMeteorProjects/issueReplication1 ]]]]]
=> Started proxy.
=> Started MongoDB.
W20150728-21:54:46.964(-4)? (STDERR)
W20150728-21:54:46.966(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:46.966(-4)? (STDERR) throw(ex);
W20150728-21:54:46.967(-4)? (STDERR) ^
W20150728-21:54:46.967(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:46.967(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:46.967(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:46.967(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:46.967(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:46.967(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:46.968(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150728-21:54:46.968(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150728-21:54:51.718(-4)? (STDERR)
W20150728-21:54:51.719(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:51.719(-4)? (STDERR) throw(ex);
W20150728-21:54:51.719(-4)? (STDERR) ^
W20150728-21:54:51.730(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:51.730(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:51.730(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:51.730(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:51.730(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:51.731(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:51.731(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150728-21:54:51.731(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150728-21:54:56.477(-4)? (STDERR)
W20150728-21:54:56.478(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:56.479(-4)? (STDERR) throw(ex);
W20150728-21:54:56.480(-4)? (STDERR) ^
W20150728-21:54:56.490(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:56.490(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:56.491(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:56.491(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:56.491(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:56.492(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:56.492(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
W20150728-21:54:56.492(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
我会尝试将您的 phaser.js 放入客户端文件夹。
请参阅有关文件结构的流星文档:http://docs.meteor.com/#/full/structuringyourapp
我认为正在发生的事情是 phaser.js 正在尝试访问节点(服务器端)中不存在的文档。该文档仅在客户端。
此外,最好将它保存在客户端文件夹中,因为它是您只想 运行 在客户端上的东西。
我已经运行独立使用 Meteor 应用程序和 Phaser 应用程序,一切都很好。但是,当我尝试 运行 使用 Meteor 的 Phaser 游戏时,我遇到了错误。
所以,一个问题是是否有人 运行 与 Meteor 一起成功使用 Phaser。
另一个 question/issue 更具体。我 运行 以下内容:
- ubuntu14.04
- 流星 1.1.0.2
- Phaser v2.3.0
我的目录包含:
- app.js
- index.html
- phaser.js
app.js:
if (Meteor.isClient) {
Template.game.game = function(){
var game = new Phaser.Game(320,320, Phaser.AUTO, 'firstGame', { preload: preload, create: create, update:update });
}
function preload(){
}
function create(){
}
function update(){
}
}
if (Meteor.isServer) {
};
}
index.html:
<body>
{{> game}}
</body>
<template name="game">
{{game}}
</template>
我运行流星时的错误是:
cmt@ubuntu:~/projects/myMeteorProjects/issueReplication1$ meteor
[[[[[ ~/projects/myMeteorProjects/issueReplication1 ]]]]]
=> Started proxy.
=> Started MongoDB.
W20150728-21:54:46.964(-4)? (STDERR)
W20150728-21:54:46.966(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:46.966(-4)? (STDERR) throw(ex);
W20150728-21:54:46.967(-4)? (STDERR) ^
W20150728-21:54:46.967(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:46.967(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:46.967(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:46.967(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:46.967(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:46.967(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:46.968(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150728-21:54:46.968(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150728-21:54:51.718(-4)? (STDERR)
W20150728-21:54:51.719(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:51.719(-4)? (STDERR) throw(ex);
W20150728-21:54:51.719(-4)? (STDERR) ^
W20150728-21:54:51.730(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:51.730(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:51.730(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:51.730(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:51.730(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:51.731(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:51.731(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150728-21:54:51.731(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150728-21:54:56.477(-4)? (STDERR)
W20150728-21:54:56.478(-4)? (STDERR) /home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150728-21:54:56.479(-4)? (STDERR) throw(ex);
W20150728-21:54:56.480(-4)? (STDERR) ^
W20150728-21:54:56.490(-4)? (STDERR) ReferenceError: document is not defined
W20150728-21:54:56.490(-4)? (STDERR) at root (app/phaser.js:2546:34)
W20150728-21:54:56.491(-4)? (STDERR) at app/phaser.js:12437:4
W20150728-21:54:56.491(-4)? (STDERR) at app/phaser.js:88287:3
W20150728-21:54:56.491(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:222:10
W20150728-21:54:56.492(-4)? (STDERR) at Array.forEach (native)
W20150728-21:54:56.492(-4)? (STDERR) at Function._.each._.forEach (/home/cmt/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
W20150728-21:54:56.492(-4)? (STDERR) at /home/cmt/projects/myMeteorProjects/issueReplication1/.meteor/local/build/programs/server/boot.js:117:5
我会尝试将您的 phaser.js 放入客户端文件夹。
请参阅有关文件结构的流星文档:http://docs.meteor.com/#/full/structuringyourapp
我认为正在发生的事情是 phaser.js 正在尝试访问节点(服务器端)中不存在的文档。该文档仅在客户端。
此外,最好将它保存在客户端文件夹中,因为它是您只想 运行 在客户端上的东西。