What's the proper way to destroy a Phaser 3 game instance?

Recommended Posts


I'm new to Phaser, so please forgive that I also posted to the Google Group on this subject.  I'm not yet sure where it's best to ask this kind of question.

I am developing a SPA with Angular2 and so am playing with Phaser 3 as it's modularity seems to enable it to be used with Angular2.

I need to be able to load a game, then close it, then load a new game in it's place.

What is the proper way to "destroy" a Phaser 3 game please?  I note that there is a destroy method in src/scene/System.js as per the attached image.  I notice the "TO DO" so it may be that this is just not implemented yet?

Any thoughts or feedback would be very welcome.

Thanks so much!




Share this post

Link to post
Share on other sites

Hi.  I am working in Angular4.  I have the following testing code, which I have adapted to include the destroy call.


<div id="phaser-example"></div>
<button (click)="MoveCarrot()">Move Carrot</button>


import { Component } from '@angular/core';

import Phaser from 'phaser';

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {
  phaserGame: Phaser.Game;
  carrot: any;
  config = {
    type: Phaser.CANVAS,
    parent: 'phaser-example',
    scene: {
        preload: function(){
          this.load.image('carrot', 'assets/carrot.png');
        create: function(){
          this.carrot = this.add.sprite(400, 300, 'carrot');

          this.input.on('pointerdown', function () {
              console.log("pointer clicked");
          }, this);


  constructor() { 
    this.phaserGame = new Phaser.Game(this.config);

  MoveCarrot() : void{
    this.phaserGame.scene.scenes[0].carrot.x += 10;


From the example at\game config\game destroy.js I would expect the game to be destroyed on mouse click.  I see the "pointer clicked" console log, but the game isn't destroyed and there is no error message.

Am I missing something please?

Thank you so much :)


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.