Jump to content

Phaser Offline. How to do it?


Recommended Posts


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

Nothing has to be online to use phaser. You have the full power of phaser in the javascript file phaser.js

If 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 - localhost


Both 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 :)

Link to comment
Share on other sites

  • 2 weeks later...

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

  • 4 months later...

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:





Kevin Sloan / February 9, 2014
The 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,'+
'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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...