Ionic 5 & Phaser 3

Hi there,
i want to develop a game with Ionic and Phaser.
I downloaded the phaser.js and imported it in the index.html

<script src="assets/phaser.js"></script>

in my home.page.html i got:

<ion-content>
  <div id="phaser-example"></div>
</ion-content>

Here is my home.page.ts

When i run it with ionic serve i can see i the web console that is has an error:
ERROR TypeError: “game.load is undefined”

I just want to start to add a text or an image to my game.

Can please someone help to get started?
Thank you :smiley:

Someone has any idea?

Thank you very much! :slight_smile:

  1. remove <script src="assets/phaser.js"></script> in index.html
  2. in root folder: angular.json, search "scripts": [], add your js file.
    eg: "scripts": ["src/phaser.min.js"]
  3. restart ng serve, ‘phaser’ should work.

Hi,

i tried this, but i still got this error:
ERROR TypeError: "game.load is undefined"

I dont know what to do :thinking:

Whether or not it solves your problem

Game should be declared as member of the class and not at the global level

Then address it through this.game