Skip to content

Commit 21df050

Browse files
committed
Works using ColInfo object now
1 parent df55ffd commit 21df050

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

src/physics/arcade/SeparateY.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,19 @@ var GetOverlapY = require('./GetOverlapY');
2626
*
2727
* @return {boolean} `true` if the two bodies overlap vertically, otherwise `false`.
2828
*/
29-
var SeparateY = function (body1, body2, overlapOnly, bias)
29+
var SeparateY = function (collisionInfo)
3030
{
31-
// console.log('');
32-
// console.log('%c frame ' + body1.world._frame + ' ', 'background-color: orange');
33-
// console.log('body1:', body1.gameObject.name, 'vs body2:', body2.gameObject.name);
34-
// console.log('pre-GetOverlap by = body1', body1.y, 'body2', body2.y);
35-
// console.log('pre-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
36-
37-
var collisionInfo = GetOverlapY(body1, body2, overlapOnly, bias);
38-
39-
// console.log(collisionInfo);
40-
// console.log('post-GetOverlap by = body1', body1.y, 'body2', body2.y);
41-
// console.log('post-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
42-
4331
var overlap = collisionInfo.overlapY;
44-
var topFace = collisionInfo.face === CONST.FACING_UP;
32+
var overlapOnly = collisionInfo.overlapOnly;
33+
34+
var topFace = collisionInfo.faceY === CONST.FACING_UP;
4535
var bottomFace = !topFace;
36+
4637
var intersects = collisionInfo.intersects;
4738

39+
var body1 = collisionInfo.body1;
40+
var body2 = collisionInfo.body2;
41+
4842
var velocity1 = body1.velocity;
4943
var velocity2 = body2.velocity;
5044

@@ -54,7 +48,18 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
5448
var body1Immovable = (body1.physicsType === CONST.STATIC_BODY || body1.immovable);
5549
var body2Immovable = (body2.physicsType === CONST.STATIC_BODY || body2.immovable);
5650

57-
// console.log('body1 overlaps body2 across the', ((topFace) ? 'top' : 'bottom'), 'by', overlap, 'px');
51+
console.log('');
52+
console.log('%c Y frame ' + body1.world._frame + ' ', 'background-color: pink');
53+
console.log('body1:', body1.gameObject.name, 'vs body2:', body2.gameObject.name);
54+
55+
// console.log('pre-GetOverlap by = body1', body1.y, 'body2', body2.y);
56+
// console.log('pre-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
57+
58+
// console.log(collisionInfo);
59+
// console.log('post-GetOverlap by = body1', body1.y, 'body2', body2.y);
60+
// console.log('post-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
61+
62+
console.log('body1 overlaps body2 across the', ((topFace) ? 'top' : 'bottom'), 'by', overlap, 'px');
5863

5964
// Can't separate two immovable bodies, or a body with its own custom separation logic
6065
if (!intersects || overlapOnly || (body1Immovable && body2Immovable) || body1.customSeparateY || body2.customSeparateY)
@@ -172,8 +177,8 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
172177
ny2 = 0;
173178
}
174179

175-
var totalA = collisionInfo.share1;
176-
var totalB = collisionInfo.share2;
180+
var totalA = collisionInfo.shareY1;
181+
var totalB = collisionInfo.shareY2;
177182

178183
// console.log('split at', totalA, totalB, 'of', overlap);
179184

0 commit comments

Comments
 (0)