Doug

Phaser3 and Ionic Framework

Recommended Posts

Hi All

I'm developing a mobile app with ionic framework and Phaser 3 and am having some problems.

When I run ionic serve the app opens in the web browser and works fine.  However, when I run ionic build I have problems.

I know that Phaser loading because I am seeing the following in the console (this is running the version that has problems when I ionic build it):

image.png.4c48b9648f27844f58bd107cf5502bf2.png

However, I get a black screen rather than any game content. 

I am including phaser in the index.html file:

<script type="text/javascript" src="assets/libs/phaser/phaser.min.js"></script>

Then referencing it within my component:

declare var Phaser: any;

As I say, it works fine until I do a full ionic build.

Anyone seen this before?  Any ideas why it would happen please?

Thanks!

Share this post


Link to post
Share on other sites

OK, so I think I may have worked out what's going on here, but I'd welcome feedback as to whether I'm correct and how to resolve it please.

When I run `ionic serve` my games run perfectly.  When I do `ionic build` and open the files directly in a browser they fail.  This, I have now realised is a dim mistake because a web server is required to serve phaser games.  So if I run a basic python web server in the www build directory with `python -m SimpleHTTPServer` I can then browse to the game in the web browser at http://localhost:8000/ and boom, the games are working.

So, the question is.....Is the reason that the games in my ionic app fail that they are not being run with a webserver when they are running in a compiled app?  If so, then how do I get around that? 

Thanks very much!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.