mirror of
https://github.com/photonstorm/phaser
synced 2024-11-25 14:10:42 +00:00
Physics Manager now calls shutdown and destroy.
Matter World properly clears out the world and its Engine on shutdown. Also fixed incorrect localWorld.remove calls (fix #3110)
This commit is contained in:
parent
31d2262cb4
commit
309cf610bb
4 changed files with 27 additions and 8 deletions
|
@ -479,6 +479,11 @@ var World = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.scene = null;
|
||||
|
|
|
@ -167,7 +167,7 @@ var World = new Class({
|
|||
{
|
||||
if (wall)
|
||||
{
|
||||
this.localWorld.remove(wall);
|
||||
MatterWorld.remove(this.localWorld, wall);
|
||||
}
|
||||
|
||||
// adjust center
|
||||
|
@ -180,7 +180,7 @@ var World = new Class({
|
|||
{
|
||||
if (wall)
|
||||
{
|
||||
this.localWorld.remove(wall);
|
||||
MatterWorld.remove(this.localWorld, wall);
|
||||
}
|
||||
|
||||
this.walls[position] = null;
|
||||
|
@ -322,12 +322,14 @@ var World = new Class({
|
|||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
MatterWorld.clear(this.localWorld, false);
|
||||
Engine.clear(this.engine);
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
|
||||
// TODO
|
||||
this.shutdown();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -243,6 +243,8 @@ var Systems = new Class({
|
|||
{
|
||||
// Was stopped by the GlobalSceneManager
|
||||
|
||||
console.log('Scene.shutdown');
|
||||
|
||||
this.settings.active = false;
|
||||
this.settings.visible = false;
|
||||
|
||||
|
@ -250,6 +252,7 @@ var Systems = new Class({
|
|||
this.updateList.shutdown();
|
||||
this.time.shutdown();
|
||||
this.tweens.shutdown();
|
||||
this.physicsManager.shutdown();
|
||||
|
||||
if (this.scene.shutdown)
|
||||
{
|
||||
|
@ -257,14 +260,13 @@ var Systems = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
// Game level nuke
|
||||
// TODO: Game level nuke
|
||||
destroy: function ()
|
||||
{
|
||||
// TODO
|
||||
|
||||
this.add.destroy();
|
||||
this.time.destroy();
|
||||
this.tweens.destroy();
|
||||
this.physicsManager.destroy();
|
||||
|
||||
// etc
|
||||
if (this.scene.destroy)
|
||||
|
|
|
@ -24,7 +24,7 @@ var PhysicsManager = new Class({
|
|||
this.system;
|
||||
|
||||
// This gets set by the physics system during boot
|
||||
this.world = { update: NOOP, postUpdate: NOOP };
|
||||
this.world = { update: NOOP, postUpdate: NOOP, shutdown: NOOP, destroy: NOOP };
|
||||
|
||||
// This gets set by the physics system during boot
|
||||
this.add;
|
||||
|
@ -70,6 +70,16 @@ var PhysicsManager = new Class({
|
|||
postUpdate: function ()
|
||||
{
|
||||
this.world.postUpdate();
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
this.world.shutdown();
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.world.destroy();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue