简体   繁体   English

流星和相位器-简单样本错误

[英]Meteor and Phaser - error with simple sample

I have been running Meteor application as well as Phaser applications standalone and everything is fine. 我一直在独立运行Meteor应用程序和Phaser应用程序,一切都很好。 However, when I try to run a Phaser game with Meteor I get errors. 但是,当我尝试使用Meteor运行Phaser游戏时,出现错误。

So, one question is if anyone runs successfully Phaser together with Meteor. 因此,一个问题是,是否有人可以与Meteor一起成功运行Phaser。

The other question/issue is more specific. 另一个问题/问题更为具体。 I run the following: 我运行以下命令:

  • ubuntu 14.04 Ubuntu 14.04
  • Meteor 1.1.0.2 流星1.1.0.2
  • Phaser v2.3.0 移相器v2.3.0

My directory contains: 我的目录包含:

  • app.js app.js
  • index.html index.html
  • phaser.js phaser.js

app.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: index.html:

    <body>
      {{> game}}
    </body>

    <template name="game">
      {{game}}
    </template>

The error when I run meteor is: 运行流星时的错误是:

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

I would try putting your phaser.js into the client folder. 我会尝试将您的phaser.js放入客户端文件夹。

See the meteor docs on file structuring: http://docs.meteor.com/#/full/structuringyourapp 请参阅有关文件结构的流星文档: http : //docs.meteor.com/#/full/structuringyourapp

What I believe is happening is phaser.js is trying to access the document, which does not exist in node (the server side). 我相信正在发生的是phaser.js试图访问该文档,该文档在节点(服务器端)中不存在。 The document is only client side. 该文档仅在客户端。

Furthermore, it would probably be good practice to just keep it in the client folder since it is something you only want to run on the client. 此外,将其保留在客户端文件夹中可能是一个好习惯,因为您只想在客户端上运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM