0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

moved collision event triggers

This commit is contained in:
liabru 2014-03-10 21:25:07 +00:00
parent 6f5e0d0036
commit 6516c5be8d

View file

@ -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);