digitsensitive Posted March 31, 2018 Share Posted March 31, 2018 Hello! I was wondering if this is the correct approach, regarding management of the collider when restarting a scene. I have added this collider in my scene: this.physics.add.collider( this.traps, this.player, this.playerTrap, null, this ); I restart the scene as soon as this collision happens in the playerTrap() function: private playerTrap(): void { this.player.setAlive(false); this.cleanScene(); this.scene.start("GameScene"); } The cleanScene(): private cleanScene(): void { this.physics.destroy(); } Without the cleanScene() function he restarts the scene infinitely. I always thought that when using this.scene.start he auto cleans everything and reboots. Link to comment Share on other sites More sharing options...
karpimpski Posted May 21, 2018 Share Posted May 21, 2018 I ran into the same issue. Please let me know if you found out any more information about this topic! Link to comment Share on other sites More sharing options...
samme Posted May 21, 2018 Share Posted May 21, 2018 Try again with the latest Phaser release. Link to comment Share on other sites More sharing options...
karpimpski Posted May 21, 2018 Share Posted May 21, 2018 Thanks so much! I was using a version from an online tutorial and didn't check to make sure it was the latest. Do you know what was happening before? I suspected the current physics object and sprites weren't being removed immediately when the scene was restarted, so it kept calling the collision method. I'm a beginner, though, so that's probably not too accurate Link to comment Share on other sites More sharing options...
samme Posted May 21, 2018 Share Posted May 21, 2018 In earlier Phaser 3 releases the physics world wasn't shut down when the scene it belonged to was shut down. Now it is. Link to comment Share on other sites More sharing options...
Recommended Posts