jit-talukdar / phaser-angular-7

Phaser 3 working around Angular 7. Step by step method to integrate phaser with Angular 7.
8 stars 4 forks source link

Getting error on re-initializing phaser game after destroying #1

Open garimabhasin opened 4 years ago

garimabhasin commented 4 years ago

Hello, I added another component on which the page is being redirected after leaving phaser game. Following is the code I am using to destroy game component -

    this.game.scene.remove('Scene');
    this.game.destroy(true);
    this.menuGameComp.exitRoom('over');

The above 'exitRoom' method is navigating to the new component I added. On click on button on new component, the navigation leads back to app component. And throwing the following error -

"ERROR TypeError: Cannot set property 'game' of null
    at PluginManager.addToScene (phaser.js:69109)
    at Systems.init (phaser.js:33612)
    at SceneManager.createSceneFromInstance (phaser.js:72938)
    at SceneManager.add (phaser.js:72583)
    at AlphacrossGameComponent.push../src/app/component/alphacross-game/alphacross-game.component.ts.AlphacrossGameComponent.onGameReady (alphacross-game.component.ts:36)
    at Object.eval [as handleEvent] (AlphacrossGameComponent.html:1)
    at handleEvent (core.js:23107)
    at callWithDebugContext (core.js:24177)
    at Object.debugHandleEvent [as handleEvent] (core.js:23904)
    at dispatchEvent"

and

ERROR CONTEXT

And getting the black screen.

Please help!

sprengerst commented 4 years ago

Same here.

I found out that sys.scene seems to be null.