Skip to content

Commit 469b74b

Browse files
committed
Handle single face intersects
1 parent b7f1888 commit 469b74b

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/physics/arcade/CollisionInfo.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,26 @@ var CollisionInfo = {
5454
{
5555
leftFace = true;
5656
touchingX = true;
57+
intersectsY = false;
5758
}
5859
else if (body1.right === body2.x)
5960
{
6061
leftFace = false;
6162
touchingX = true;
63+
intersectsY = false;
6264
}
6365

6466
if (body1.y === body2.bottom)
6567
{
6668
topFace = true;
6769
touchingY = true;
70+
intersectsX = false;
6871
}
6972
else if (body1.bottom === body2.y)
7073
{
7174
topFace = false;
7275
touchingY = true;
76+
intersectsX = false;
7377
}
7478

7579
var faceX = CONST.FACING_NONE;
@@ -94,7 +98,7 @@ var CollisionInfo = {
9498

9599
if (!body1.immovable)
96100
{
97-
shareX1 = body1.getMoveX(share);
101+
shareX1 = body1.getShareX(share);
98102
}
99103

100104
if (shareX1 < share)
@@ -104,7 +108,7 @@ var CollisionInfo = {
104108

105109
if (!body2.immovable)
106110
{
107-
shareX2 = body2.getMoveX(-share);
111+
shareX2 = body2.getShareX(-share);
108112
}
109113
}
110114
else
@@ -125,7 +129,7 @@ var CollisionInfo = {
125129

126130
if (!body2.immovable)
127131
{
128-
shareX2 = body2.getMoveX(share);
132+
shareX2 = body2.getShareX(share);
129133
}
130134

131135
if (shareX2 < share)
@@ -135,7 +139,7 @@ var CollisionInfo = {
135139

136140
if (!body1.immovable)
137141
{
138-
shareX1 = body1.getMoveX(-share);
142+
shareX1 = body1.getShareX(-share);
139143
}
140144
}
141145
else
@@ -157,7 +161,7 @@ var CollisionInfo = {
157161

158162
if (!body1.immovable)
159163
{
160-
shareY1 = body1.getMoveY(share);
164+
shareY1 = body1.getShareY(share);
161165
}
162166

163167
if (shareY1 < share)
@@ -167,7 +171,7 @@ var CollisionInfo = {
167171

168172
if (!body2.immovable)
169173
{
170-
shareY2 = body2.getMoveY(-share);
174+
shareY2 = body2.getShareY(-share);
171175
}
172176
}
173177
else
@@ -188,7 +192,7 @@ var CollisionInfo = {
188192

189193
if (!body2.immovable)
190194
{
191-
shareY2 = body2.getMoveY(share);
195+
shareY2 = body2.getShareY(share);
192196
}
193197

194198
if (shareY2 < share)
@@ -198,7 +202,7 @@ var CollisionInfo = {
198202

199203
if (!body1.immovable)
200204
{
201-
shareY1 = body1.getMoveY(-share);
205+
shareY1 = body1.getShareY(-share);
202206
}
203207
}
204208
else
@@ -241,17 +245,20 @@ var CollisionInfo = {
241245

242246
if (forceX)
243247
{
248+
console.log('forceX');
244249
console.log('body1 overlaps body2 on the ' + ((faceX === CONST.FACING_LEFT) ? 'left' : 'right') + ' face');
245250
}
246251
else
247252
{
253+
console.log('forceY');
248254
console.log('body1 overlaps body2 on the ' + ((faceY === CONST.FACING_UP) ? 'top' : 'bottom') + ' face');
249255
}
250256

251257
console.log('overlapX:', overlapX, 'overlapY:', overlapY);
252258
console.log('shareX1:', shareX1, 'shareX2:', shareX2);
253259
console.log('shareY1:', shareY1, 'shareY2:', shareY2);
254260
console.log('x compare (CI): ', body1.right, 'body2', body2.x, '=', (body1.right - body2.x));
261+
console.log('y compare (CI): ', body1.bottom, 'body2', body2.y, '=', (body1.bottom - body2.y));
255262
};
256263

257264
if (data)

0 commit comments

Comments
 (0)