mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -05:00
moved collision event triggers
This commit is contained in:
parent
6f5e0d0036
commit
6516c5be8d
1 changed files with 23 additions and 18 deletions
|
@ -142,10 +142,32 @@ var Engine = {};
|
||||||
|
|
||||||
Events.trigger(engine, 'tick beforeUpdate', event);
|
Events.trigger(engine, 'tick beforeUpdate', event);
|
||||||
|
|
||||||
|
// update
|
||||||
Engine.update(engine, delta, correction);
|
Engine.update(engine, delta, correction);
|
||||||
|
|
||||||
|
var pairs = engine.pairs;
|
||||||
|
|
||||||
|
if (pairs.collisionStart.length > 0) {
|
||||||
|
Events.trigger(engine, 'collisionStart', {
|
||||||
|
pairs: pairs.collisionStart
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pairs.collisionActive.length > 0) {
|
||||||
|
Events.trigger(engine, 'collisionActive', {
|
||||||
|
pairs: pairs.collisionActive
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pairs.collisionEnd.length > 0) {
|
||||||
|
Events.trigger(engine, 'collisionEnd', {
|
||||||
|
pairs: pairs.collisionEnd
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Events.trigger(engine, 'afterUpdate beforeRender', event);
|
Events.trigger(engine, 'afterUpdate beforeRender', event);
|
||||||
|
|
||||||
|
// render
|
||||||
if (engine.render.options.enabled)
|
if (engine.render.options.enabled)
|
||||||
engine.render.controller.world(engine);
|
engine.render.controller.world(engine);
|
||||||
|
|
||||||
|
@ -199,23 +221,6 @@ var Engine = {};
|
||||||
Manager.updatePairs(pairs, collisions);
|
Manager.updatePairs(pairs, collisions);
|
||||||
Manager.removeOldPairs(pairs);
|
Manager.removeOldPairs(pairs);
|
||||||
|
|
||||||
// trigger collision events
|
|
||||||
if (pairs.collisionStart.length > 0) {
|
|
||||||
Events.trigger(engine, 'collisionStart', {
|
|
||||||
pairs: pairs.collisionStart
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (pairs.collisionActive.length > 0) {
|
|
||||||
Events.trigger(engine, 'collisionActive', {
|
|
||||||
pairs: pairs.collisionActive
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (pairs.collisionEnd.length > 0) {
|
|
||||||
Events.trigger(engine, 'collisionEnd', {
|
|
||||||
pairs: pairs.collisionEnd
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// wake up bodies involved in collisions
|
// wake up bodies involved in collisions
|
||||||
if (engine.enableSleeping)
|
if (engine.enableSleeping)
|
||||||
Sleeping.afterCollisions(pairs.list);
|
Sleeping.afterCollisions(pairs.list);
|
||||||
|
|
Loading…
Reference in a new issue