The physics world is now cleared on state swap (fixes #505)

This commit is contained in:
photonstorm 2014-03-02 11:04:04 +00:00
parent 33da238e97
commit 66bdf56349
2 changed files with 18 additions and 0 deletions

View file

@ -286,6 +286,11 @@ Phaser.StateManager.prototype = {
this.game.world.destroy();
if (this.game.physics)
{
this.game.physics.clear();
}
if (this._clearCache === true)
{
this.game.cache.destroy();

View file

@ -455,6 +455,19 @@ Phaser.Physics.World.prototype = {
},
/**
* Clears all bodies from the simulation.
*
* @method Phaser.Physics.World#clear
*/
clear: function () {
this.world.clear();
},
/**
* Clears all bodies from the simulation and unlinks World from Game. Should only be called on game shutdown. Call `clear` on a State change.
*
* @method Phaser.Physics.World#destroy
*/
destroy: function () {