Jump to content

Phaser + NPM + ES6 = this-keyword problems


Tailball
 Share

Recommended Posts

So as a practise project, I am trying to get Phaser running in my React-Redux-Nodejs application.

There is an NPM package which I am using (https://www.npmjs.com/package/phaser)

Everything works ok and my React app is able to launch Phaser!

However, since I am using ES6 syntax and class-based objects, I have no idea how to proceed...
You can find my boilerplate code here: https://pastebin.com/4mmUhtQZ

- My React component should be fine. Everything loads up and I get my black 800x600 canvas.
- My config class basically works and shoots the config into the game object.
! I use the example from the Phaser 3 tutorials, which just loads in a .js script file and uses the this keyword in basic <script> tags.
Because I am using a class-based syntax, the this keyword refers to my class and not to the Phaser object. I would like to keep it that way, so that my classes can use the this keyword in order to access local components.
This means that I should refer to the original this (the one the Phaser tutorial wants me to use) keyword some other way. 

Please help me out :) thanks in advance!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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