Skip to content

Commit 1a50665

Browse files
committed
Function not triggering properly. Adding to Body directly.
1 parent 819a6b2 commit 1a50665

2 files changed

Lines changed: 25 additions & 28 deletions

File tree

src/physics/matter-js/lib/body/Body.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ var Axes = require('../geometry/Axes');
6363
isSleeping: false,
6464
ignoreGravity: false, // custom Phaser property
6565
ignorePointer: false, // custom Phaser property
66+
onCollideCallback: null, // custom Phaser property
67+
onCollideEndCallback: null, // custom Phaser property
68+
onCollideActiveCallback: null, // custom Phaser property
6669
motion: 0,
6770
sleepThreshold: 60,
6871
density: 0.001,
@@ -115,6 +118,28 @@ var Axes = require('../geometry/Axes');
115118

116119
_initProperties(body, options);
117120

121+
// Merge in the Matter Collision Events plugin defaults:
122+
body.setOnCollide = function (callback)
123+
{
124+
this.onCollideCallback = callback;
125+
126+
return this;
127+
}
128+
129+
body.setOnCollideEnd = function (callback)
130+
{
131+
this.onCollideEndCallback = callback;
132+
133+
return this;
134+
}
135+
136+
body.setOnCollideActive = function (callback)
137+
{
138+
this.onCollideActiveCallback = callback;
139+
140+
return this;
141+
}
142+
118143
return body;
119144
};
120145

src/physics/matter-js/lib/plugins/MatterCollisionEvents.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,6 @@ var MatterCollisionEvents = {
1313

1414
install: function (matter)
1515
{
16-
matter.after('Body.create', function (body)
17-
{
18-
body.onCollideCallback;
19-
body.onCollideEndCallback;
20-
body.onCollideActiveCallback;
21-
22-
body.setOnCollide = function (callback)
23-
{
24-
this.onCollideCallback = callback;
25-
26-
return this;
27-
}
28-
29-
body.setOnCollideEnd = function (callback)
30-
{
31-
this.onCollideEndCallback = callback;
32-
33-
return this;
34-
}
35-
36-
body.setOnCollideActive = function (callback)
37-
{
38-
this.onCollideActiveCallback = callback;
39-
40-
return this;
41-
}
42-
});
43-
4416
matter.after('Engine.create', function ()
4517
{
4618
matter.Events.on(this, 'collisionStart', function (event)

0 commit comments

Comments
 (0)