Phaser API Documentation


Member of: Phaser.Game

destroy(removeCanvas, [noReturn])


Flags this Game instance as needing to be destroyed on the next frame, making this an asynchronous operation.

It will wait until the current frame has completed and then call runDestroy internally.

If you need to react to the games eventual destruction, listen for the DESTROY event.

If you do not need to run Phaser again on the same web page you can set the noReturn argument to true and it will free-up memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as false.


name type arguments Default description
removeCanvas boolean

Set to true if you would like the parent canvas element removed from the DOM, or false to leave it in place.

noReturn boolean <optional> false

If true all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this.

Since: 3.0.0
Source: src/core/Game.js (Line 638)