title: phaser 3 reset the whole scene
body: <p>Following the phaser documentation, the scene restart is not working.</p>
  <p>What I'm doing is the following, there are three scenes (start, play and end.). When it gets to the end, when clicking on the screen it gives this.scene.start('play'). I tried several ways, researched a lot and tried several things but the ones that worked in my case, the game for some events and some settings are not reset.
  For example, in this game you will create enemies and some packs. When it is restarted or started again, these builds are no longer executed.</p>
  <p>Start</p>
  <pre><code>import Phaser from &quot;phaser&quot;;
  
  class Start extends Phaser.Scene{
  
      constructor ()
      {
          super({ key: 'start', active: true });
      }
  
  
      init(){
          console.log(&quot;- ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./pages/game/index.vue?vue&amp;type=script&amp;lang=js&amp;&quot;)
          console.log(&quot;initiated 0418971&quot;)
          console.log(&quot;Unexpected console statement  no-console&quot;)
          console.log(&quot;bundle 'client' has 1 warnings&quot;)
          console.log(&quot;Caching create all&quot;)
          this.cameras.main.setBackgroundColor(&quot;#24252A&quot;);
      }
  
      preload(){
  
      }
  
      create() {
          this.helloWorld = this.add.text(
              this.cameras.main.centerX,
              this.cameras.main.centerY,
              &quot;Clique para jogar&quot;,
              { font: &quot;40px Arial&quot;,  fill: &quot;#ffffff&quot; }
            );
            this.helloWorld.setOrigin(0.5);
  
          this.input.on('pointerup', function (pointer) {
  
              this.scene.start('play');
  
          }, this);
      }
  
      update() {
  
      }
  
  }
  
  export default Start;
  </code></pre>
  <p>Play</p>
  <pre><code>import Phaser from &quot;phaser&quot;;
  // import Pack from '~/assets/game/Components/Pack.js'
  
  class Play extends Phaser.Scene {
  
    constructor() {
      super({
        key: 'play',
        active: false
      });
    }
  
    index = 0;
    packs = Phaser.GameObjects.Group;
    enemys = Phaser.GameObjects.Group;
    spriteLife = [];
  
    config = {
      speed: 0,
      speedVelocity: 0.3,
      maxSpeed: 15,
      pack: {
        created: 0,
        limitcreate: 1,
        value: 4.5,
      },
      enemy: {
        speed: 5,
        created: 0,
        limitcreate: 1,
        x: 0,
      },
      engine: {
        temperature: 0,
      }
    };
  
    init() {
    }
  
    preload() {
      // Images
      this.load.image('grama', require('~/assets/game/assets/grama.jpg'));
      this.load.image('road', require('~/assets/game/assets/road-2.png'))
      this.load.image('pack', require('~/assets/game/assets/pack.png'));
      this.load.image('life', require('~/assets/game/assets/life.png'));
  
      // Sprite sheet
      this.load.spritesheet('player', require('~/assets/game/assets/car-sprite.png'), {
        frameWidth: 404,
        frameHeight: 1009
      })
    }
  
    createGram() {
      let a = 0;
      let b = 0;
      const totalA = 8;
      const totalB = 4;
  
      for (a = 0; a &lt;= totalA; a++) {
        for (b = 0; b &lt;= totalB; b++) {
          const grama = this.add.sprite(0, 0, 'grama').setScale(0.2);
          grama.setPosition(grama.displayWidth * b, grama.displayHeight * a);
  
        }
      }
    }
  
    createScore() {
      this.score = 0;
  
      this.scoreText = this.add.text(15, 45,
        `SCORE: 0`, {
          font: &quot;20px Arial&quot;,
          fill: &quot;#ffffff&quot;
        }
      );
    }
  
    createLife() {
      this.numberLifes = 3;
  
      this.add.text(15, 15,
        `LIFE:`, {
          font: &quot;20px Arial&quot;,
          fill: &quot;#ffffff&quot;
        }
      );
  
      for (let i = 0; i &lt; this.numberLifes; i++) {
        this.spriteLife.push(this.add.image(80 + 30 * i, 25, 'life').setScale(0.09))
      }
    }
  
    createPlayer() {
      this.player = this.physics.add.sprite(0, 0, 'player');
      this.player.setOrigin(0.5)
      this.player.setScale(0.2);
      this.player.setPosition(this.cameras.main.centerX, this.cameras.main.displayHeight - 120);
  
      this.player.setCollideWorldBounds(true);
    }
  
    createPack() {
      if(this.config.pack.created &lt; this.config.pack.limitcreate){
        this.packs.create(Phaser.Math.Between(60, 330), 0, 'pack').setScale(.15).setOrigin(.5);
        this.config.pack.created += 1;
      }
    }
  
    createEnemy() {
      if(this.config.enemy.created &lt; this.config.enemy.limitcreate){
        this.enemy = this.enemys.create(Phaser.Math.Between(70, 320), -200, 'player').setScale(.2).setOrigin(.5);
        this.enemy.anims.play('default', true);
        this.config.enemy.created += 1;
        this.config.enemy.x = this.enemys.children.entries[0].x;
      }
    }
  
    createEngineTemperatureBar() {
      this.engineTemperatureBar = this.add.graphics();
      this.engineTemperatureBar.fillStyle(0xffffff, 1);
      this.engineTemperatureBar.fillRect(0, 0, 130, 30);
  
      // Position
      this.engineTemperatureBar.x = 350;
      this.engineTemperatureBar.y = 830;
      this.engineTemperatureBar.angle = -90;
      this.engineTemperatureBar.scaleX = 0;
    }
  
    myAnims() {
      this.anims.create({
        key: 'left',
        frames: this.anims.generateFrameNumbers('player', {
          start: 4,
          end: 4
        }),
        frameRate: 3,
        repeat: 0
      })
  
      this.anims.create({
        key: 'right',
        frames: this.anims.generateFrameNumbers('player', {
          start: 0,
          end: 1
        }),
        frameRate: 3,
        repeat: 0
      })
  
      this.anims.create({
        key: 'default',
        frames: [{
          key: 'player',
          frame: 2
        }],
        frameRate: 20
      });
    }
  
    addPhysics(){
      // Add
      this.packs = this.physics.add.group();
      this.enemys = this.physics.add.group();
  
      // Collider
      this.physics.add.collider(this.player, this.packs, this.collectPack, null, this);
      this.physics.add.collider(this.player, this.enemys, this.collideEnemy, null, this, this.enemys);
    }
  
    create() {
      // Camera
      this.cameras.main.setBackgroundColor(&quot;#24252A&quot;);
  
      // Gram
      this.createGram();
  
      // Roads
      this.roads = this.add.tileSprite((this.game.canvas.clientWidth / 2), 0, 500, 1210, 'road').setOrigin(0.5, 0).setScale(0.7);
  
      // Functions
      this.createScore();
      this.createLife();
      this.createPlayer();
      this.myAnims();
      this.addPhysics();
      this.createEngineTemperatureBar();
  
      // Body
      this.packs.enableBody = true;
      this.enemys.enableBody = true;
  
      // Cursors
      this.cursors = this.input.keyboard.createCursorKeys();
    }
  
    update(time) {
      this.roads.tilePositionY -= this.config.speed;
  
      this.movePlayerManager();
      this.createPack();
      this.createEnemy();
      this.movePacks();
      this.moveEnemy()
      this.updateEngineTemperatureBar()
    }
  
    movePlayerManager() {
      // Left
      if (this.cursors.left.isDown) {
        this.player.x -= 5;
        this.player.anims.play('left', false);
      }
      // Right
      else if (this.cursors.right.isDown) {
        this.player.x += 5;
        this.player.anims.play('right', false);
      }
      else {
        this.player.anims.play('default', true);
      }
  
      // Up
      if (this.cursors.up.isDown) {
        // Increase speed
        if (this.config.speed &lt;= this.config.maxSpeed){
          this.config.speed += this.config.speedVelocity;
        }
      }
  
      if (this.cursors.up.isUp) {
        if (this.config.speed &gt; 0){
          this.config.speed -= 0.5;
        }
        else
          this.config.speed = 0
      }
  
    }
  
    movePacks() {
      this.packs.children.each((e) =&gt; {
        e.y += this.config.speed;
  
        if(e.y &gt; this.game.config.height){
          e.destroy();
          this.config.pack.created -= 1;
        }
      })
    }
  
    moveEnemy() {
      this.enemys.children.each((e) =&gt; {
        if(this.cursors.up.isDown){
          if(this.config.speed &lt; this.config.maxSpeed-1){
            e.y -= this.config.maxSpeed;
            return
          };
            
          e.y += this.config.enemy.speed;
  
          // Move left or right
          if(this.config.enemy.x &lt; 150 &amp;&amp; e.x &lt; 290){
            e.x += 1;
            this.enemy.anims.play('right', true);
          }
          else if(e.x &gt; 90){
            e.x -= 1;
            this.enemy.anims.play('left', true);
          }else{
            this.enemy.anims.play('default', true);
          }
        }else{
          if(e.y &lt; -1000) return;
  
          e.y -= this.config.maxSpeed;
        }
  
        if(e.y - 200 &gt; this.game.config.height){
          e.destroy();
          this.config.enemy.created -= 1;
        }
      })
    }
  
    updateEngineTemperatureBar(){
      if(this.cursors.up.isDown &amp;&amp; this.config.engine.temperature &lt;= 100){
        this.config.engine.temperature += 0.1;
      }
      else if(this.cursors.up.isUp &amp;&amp; this.config.engine.temperature &lt; 100){
        this.config.engine.temperature += 0.2;
      }else{
        this.scene.start('end', { motiveText: &quot;O motor do seu carro explodiu.&quot; });
      }
  
      // change the size of the bar
      this.engineTemperatureBar.scaleX = this.config.engine.temperature/100;
    }
  
    updateLifes(){
      if(this.numberLifes &lt;= 1){
        this.scene.start('end', { motiveText: &quot;Suas vidas acabaram.&quot; });
      }else{
        this.spriteLife[this.numberLifes-1].destroy();
        this.numberLifes = this.numberLifes -1;
      }
    }
  
    collectPack(player, pack){
      // Destroy pack
      pack.disableBody(true, true);
      pack.destroy();
  
      // Config
      this.config.pack.created -= 1;
  
      // Score
      this.score++;
      this.scoreText.setText(&quot;SCORE: &quot; + this.score);
  
      // Engien temperature bar
      if(this.config.engine.temperature &gt; 1)
        this.config.engine.temperature -= this.config.pack.value;
    }
  
    collideEnemy(player, enemy){
      // Life
      this.updateLifes();
      
      // Destroy
      enemy.destroy();
      
      // Config
      this.config.speed = 1;
      this.config.enemy.created -= 1;
    }
  }
  
  export default Play;
  
  </code></pre>
  <p>End</p>
  <pre><code>import Phaser from &quot;phaser&quot;;
  
  class End extends Phaser.Scene{
  
      constructor ()
      {
          super({ key: 'end', active: false });
      }
  
  
      init(data){
          this.motiveText = data.motiveText;
      }
      
      preload(){
          
      }
      
      create() {
          this.helloWorld = this.add.text(
              this.cameras.main.centerX,
              this.cameras.main.centerY,
              &quot;Perdeu!&quot;,
              { font: &quot;40px Arial&quot;,  fill: &quot;#ffffff&quot; }
          );
          this.helloWorld.setOrigin(0.5);
          
          this.helloWorld = this.add.text(
              this.cameras.main.centerX,
              this.cameras.main.centerY + 40,
              this.motiveText,
              { font: &quot;20px Arial&quot;,  fill: &quot;#ffffff&quot; }
          );
          this.helloWorld.setOrigin(0.5);
  
          this.helloWorld = this.add.text(
              this.cameras.main.centerX,
              this.cameras.main.centerY + 70,
              &quot;Clique para jogar novamente.&quot;,
              { font: &quot;20px Arial&quot;,  fill: &quot;#ffffff&quot; }
          );
          this.helloWorld.setOrigin(0.5);
  
          this.input.on('pointerup', function (pointer) {
  
              this.scene.start(&quot;start&quot;);
  
          }, this);
      }
  
      update() {
  
      }
  
  }
  
  export default End;
  </code></pre>
  <p>Again, the problem is that he doesn't completely rest. Even using the 'restart' methods, destroying the events and restarting them.</p>