From 70600a8c11631ac5bc4be9f24c4512d39e616acb Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 4 Jan 2022 10:54:34 +0000 Subject: [PATCH] changed engine collisionStart event to trigger after resolving and after updating body velocities --- src/core/Engine.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/Engine.js b/src/core/Engine.js index 5d529a3..20176a2 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -147,10 +147,6 @@ var Body = require('../body/Body'); if (engine.enableSleeping) Sleeping.afterCollisions(pairs.list, delta); - // trigger collision events - if (pairs.collisionStart.length > 0) - Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); - // iteratively resolve position between collisions Resolver.preSolvePosition(pairs.list); for (i = 0; i < engine.positionIterations; i++) { @@ -175,6 +171,9 @@ var Body = require('../body/Body'); Engine._bodiesUpdateVelocities(allBodies); // 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 });