mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
Colliders can now be toggled from active to inactive.
Collider.destroy added (but needs doing in World too).
This commit is contained in:
parent
b062e204dc
commit
f165acfe5f
2 changed files with 27 additions and 1 deletions
|
@ -10,6 +10,8 @@ var Collider = new Class({
|
|||
{
|
||||
this.world = world;
|
||||
|
||||
this.active = true;
|
||||
|
||||
this.overlapOnly = overlapOnly;
|
||||
|
||||
this.object1 = object1;
|
||||
|
@ -30,6 +32,20 @@ var Collider = new Class({
|
|||
this.callbackContext,
|
||||
this.overlapOnly
|
||||
);
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.world.removeCollider(this);
|
||||
|
||||
this.world = null;
|
||||
|
||||
this.object1 = null;
|
||||
this.object2 = null;
|
||||
|
||||
this.collideCallback = null;
|
||||
this.processCallback = null;
|
||||
this.callbackContext = null;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -249,6 +249,11 @@ var World = new Class({
|
|||
return collider;
|
||||
},
|
||||
|
||||
removeCollider: function (collider)
|
||||
{
|
||||
// TODO
|
||||
},
|
||||
|
||||
update: function (time, delta)
|
||||
{
|
||||
if (this.isPaused || this.bodies.size === 0)
|
||||
|
@ -286,7 +291,12 @@ var World = new Class({
|
|||
|
||||
for (i = 0; i < this.colliders.length; i++)
|
||||
{
|
||||
this.colliders[i].update();
|
||||
var collider = this.colliders[i];
|
||||
|
||||
if (collider.active)
|
||||
{
|
||||
collider.update();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue