tips4design Posted March 6, 2015 Share Posted March 6, 2015 I am trying to run Phaser on a Node server, I did it as described here: http://www.html5gamedevs.com/topic/7393-running-phaser-on-nodejs-how-i-did-it-and-why-you-shouldnt-do-it/Everything seems ok (the script starts Phaser, enters the boot state). The problem is that it makes an XHR request and throws error at this._xhr.open. This may be because I load resources (sprite images). How can I overcome this problem? I have tried installing a Node XHR, but says the protocol is not valid (the protocol used by Phaser when loading an image I guess). How can I correctly load sprites? Or, how can I stop sprites from loading (be able to use them, but as empty images, anyway I don't render them on the server). Spent a few hours on this and still no results, any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
tips4design Posted March 6, 2015 Author Share Posted March 6, 2015 Using this XHR instead of the default XHR module seemed to have fix the problem: https://www.npmjs.com/package/local-xmlhttprequest Some other tips for running a Phaser game on NodejS using the exact same code as on the client: Most of the steps here still apply: http://www.html5game...shouldnt-do-it/ . Encountered problems while installing node canvas, fixed them by isntalling Node.js 32bit instead of 64bit.Use requireJS client and server side, because on node there is no index.html file in which you can include script tagsDefine each of your game files as requireJS modules, make sure to use a define gist to work with requireJS on the serverI needed to use the above library, local-xhtmlhttprequest in order to be able to load images on the server. I encountered some problems with the paths (first XHR request was fine, second was requesting from the node_modules folder instead of the correct path). Hack fixed it by using the absolute path. Link to comment Share on other sites More sharing options...
Recommended Posts