Skip to content

Commit 3a0c276

Browse files
committed
preDestroy added and event fix.
1 parent 81275a6 commit 3a0c276

6 files changed

Lines changed: 15 additions & 3 deletions

File tree

v3/src/physics/matter-js/MatterImage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ var MatterImage = new Class({
5959
}
6060

6161
this.setPosition(x, y);
62+
},
63+
64+
preDestroy: function ()
65+
{
66+
this.world.remove(this.body, true);
6267
}
6368

6469
});

v3/src/physics/matter-js/MatterSprite.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ var MatterSprite = new Class({
6262
}
6363

6464
this.setPosition(x, y);
65+
},
66+
67+
preDestroy: function ()
68+
{
69+
this.world.remove(this.body, true);
6570
}
6671

6772
});

v3/src/physics/matter-js/World.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ var World = new Class({
115115

116116
MatterEvents.on(this.engine, 'collisionEnd', function (event) {
117117

118+
console.log(event);
119+
118120
localEvents.dispatch(new PhysicsEvent.COLLISION_END(event));
119121

120122
});

v3/src/physics/matter-js/events/CollisionActiveEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var CollisionActiveEvent = new Class({
1313

1414
this.pairs = pairs;
1515

16-
if (pairs.length === 1)
16+
if (pairs.length > 0)
1717
{
1818
this.bodyA = pairs[0].bodyA;
1919
this.bodyB = pairs[0].bodyB;

v3/src/physics/matter-js/events/CollisionEndEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var CollisionEndEvent = new Class({
1313

1414
this.pairs = pairs;
1515

16-
if (pairs.length === 1)
16+
if (pairs.length > 0)
1717
{
1818
this.bodyA = pairs[0].bodyA;
1919
this.bodyB = pairs[0].bodyB;

v3/src/physics/matter-js/events/CollisionStartEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var CollisionStartEvent = new Class({
1313

1414
this.pairs = pairs;
1515

16-
if (pairs.length === 1)
16+
if (pairs.length > 0)
1717
{
1818
this.bodyA = pairs[0].bodyA;
1919
this.bodyB = pairs[0].bodyB;

0 commit comments

Comments
 (0)