Phaser API Documentation

  Version: 
destroy()

Description:

Destroys this Layer removing it from the Display List and Update List and severing all ties to parent resources.

Also destroys all children of this Layer. If you do not wish for the children to be destroyed, you should move them from this Layer first.

Use this to remove this Layer from your game if you don't ever plan to use it again. As long as no reference to it exists within your own code it should become free for garbage collection by the browser.

If you just want to temporarily disable an object then look at using the Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.

Since: 3.50.0