Salvatore Posted March 9, 2014 Share Posted March 9, 2014 Hi!How to use Phaser with full power on offline devices? My game is not an online only experience...How to get working? In a close future there will be a mobile app friendly version of Phaser? So we can distribute with PhoneGap, CocoonJS, etc... Thank you! Link to comment Share on other sites More sharing options...
Heppell08 Posted March 9, 2014 Share Posted March 9, 2014 Nothing has to be online to use phaser. You have the full power of phaser in the javascript file phaser.jsIf a mobile or tablet plays a game made with phaser then you would already have the phaser file in the source code so it would work no matter what. With or without internet connection. If you wanted to test your phaser games offline without needing to use a host for you game then you have a few choices:WAMP server - localhostNode-WebkitBoth them options allow for offline testing but I'm sure that is said in the getting started guide for using phaser.Hope this answers your question kawasa_ki29 1 Link to comment Share on other sites More sharing options...
Salvatore Posted March 18, 2014 Author Share Posted March 18, 2014 So... I really have to use a server? A local one for offline matters? It does not work without a server? Link to comment Share on other sites More sharing options...
valueerror Posted March 18, 2014 Share Posted March 18, 2014 for security reasons.. yes read here:http://phaser.io/getting-started-js.php but there are several ways to create a local webserver without installing apache2 for example:http://flexible.xapient.net/?p=957 Link to comment Share on other sites More sharing options...
Zenryo Posted March 18, 2014 Share Posted March 18, 2014 If you use NetBeans and click on the Play button it will simulate a server, so you can test your games offline. But there are many other possibilities too, but I think this one is the easiest. Link to comment Share on other sites More sharing options...
Starboar Posted March 18, 2014 Share Posted March 18, 2014 Firefox will run most things from a local drive, if you just want to try things. Chrome is stricter. Clone the phaser examples github and open it the index.html in Firefox, *most* examples work. Link to comment Share on other sites More sharing options...
lenrok258 Posted March 19, 2014 Share Posted March 19, 2014 I've tried to develop game in Phaser just by opening it in browser (without local http server) but I've got an error:The cross-origin image at file:///C:(...) may not be loaded. p To overcome this problem I've launched Chrome with flag "--allow-file-access-from-files" and for the time being it works like a charm.For Firefox there is similar option in about:config. My game is very, very simple so there is a chance that some new errors will appear in more complex projects but for me this is enough. Please let me know if this work for you and if you have noticed any problem with this approach. Link to comment Share on other sites More sharing options...
ivanix Posted July 21, 2014 Share Posted July 21, 2014 Hi all, I found this link a while back. Not sure if the writer already posted his solution in this forum, but I'll link to his blog from this thread in case it may help someone in the future: http://ksloan.net/how-to-run-phaser-html5-game-engine-without-a-web-server/ <quote>Kevin Sloan / February 9, 2014The Phaser engine forces you to load your app in a web server because it uses Cross-Origin-Resource-Sharing to load assets. This is a problem if you want to run your HTML5 game locally or wrap it up and run it in a native PhoneGap App. The solution for me was to simply encode the sprites/audio I was using in base64 and include that in my js. I only had to change a few lines in the Phaser.Loader module: file.data.src = file.url;// file.data.crossOrigin = this.crossOrigin;// file.data.src = this.baseURL + file.url;Then instead of passing in the URL to the file, pass in the data itself like so: game.load.spritesheet('birdie', 'data:image/png;base64,'+'iVBORw0KGgoAAAANSUhEUgAAAGAAAAATCAYAAABvLghXAAABZElEQVR42u2YUQrCMAyGdwjB13kP'+'z7GrCJ5qexC8mw8VnZOsa5K/TXAbthDEKV/+Jk3Wtmn0ERjzGpWvAU99tzCDs8qX4BRyvJ5nnxRM'+'R4aTpNiU8L3xpxhZ+Kp4OokIHkqTm/q+B753fFihXKll9j1Y/B74NEZxokv4LKDrL1+TJqk4E1em'+'NIkSPuIj/j2X753sZB+jwZcS8Hr+CEsjTsziET4NajukWe3HNqa/EVe+lAAOHjmBVnmO+BSfC/gi'+'AcPm9M8rwJIApszU6or59L8oH1lArUE/ukDjdyjA9y8xrYdOAkpbHMK3tFBUP3oeUPhyGRe+ZCA+'+'MoFSvpZgabeH6neKz+iE2zkgvQ/Y55omUcrPTLC7/uhwhh2xDdnN5mfup2E+x0o9t+h3js/Sibaf'+'LrjrCLknyj/jzy+bnC+xVuML/d7MVw519Zp4x/xx3G+HQD8r/4f8Gpx1+W8wtcr35z8BKzsYemDt'+'gtgAAAAASUVORK5CYII=', 24, 19) You can use the same trick to load audio and other assets if you need too. Just read over that switch to see the ways Phaser loads each filetype, and replace it with the data. Obviously this is a quick fix, but it did everything I needed.<end quote> Link to comment Share on other sites More sharing options...
ivanix Posted July 21, 2014 Share Posted July 21, 2014 Oh, and Rich already posted that phaser supports data uris a while back http://www.html5gamedevs.com/topic/4167-crossorigin-issue-using-data-uris/ Link to comment Share on other sites More sharing options...
Recommended Posts