proyecto26 / ion-phaser

A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
https://market.ionicframework.com/plugins/ionphaser
MIT License
251 stars 39 forks source link

Using a custom `Phaser.Game` class #32

Closed eli-s-r closed 3 years ago

eli-s-r commented 3 years ago

Hi! I'm having issues getting this to work with my setup which uses a custom class that extends Phaser.Game (necessary as there's data that needs to be passed into the game and its scenes from React). I noticed that the game is initialized by instantiating a new Phaser.Game directly, but can't find a way to customize this. I'm also a bit confused as to the purpose of the instance prop on the GameInstance type, as instantiating the game externally doesn't allow for the necessary ref to be passed into the game. Is there any way I might be able to get around this?

Thank you so much!

jdnichollsc commented 3 years ago

For that specific scenario I recommend you using Phaser with React hooks instead, e.g: https://stackblitz.com/edit/react-phaser