Skip to content

Commit 2317cb2

Browse files
committed
Emits new TOUCH event
1 parent 5eebdff commit 2317cb2

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

src/physics/arcade/World.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,41 +1392,40 @@ var World = new Class({
13921392
}
13931393
}
13941394

1395-
var resultX = false;
1396-
var resultY = false;
1397-
13981395
var collisionInfo = GetOverlap(body1, body2, overlapOnly, this.OVERLAP_BIAS);
13991396

14001397
if (collisionInfo.intersects)
14011398
{
1399+
// console.log('%c Separate ' + this._frame + ' ', 'background-color: yellow');
1400+
// collisionInfo.dump();
1401+
14021402
if (collisionInfo.forceX)
14031403
{
1404-
resultX = SeparateX(collisionInfo);
1404+
SeparateX(collisionInfo);
14051405
}
14061406
else
14071407
{
1408-
resultY = SeparateY(collisionInfo);
1408+
SeparateY(collisionInfo);
14091409
}
1410-
}
1411-
1412-
var result = (resultX || resultY);
14131410

1414-
if (result)
1415-
{
14161411
if (overlapOnly)
14171412
{
14181413
if (body1.onOverlap || body2.onOverlap)
14191414
{
1420-
this.emit(Events.OVERLAP, body1.gameObject, body2.gameObject, body1, body2);
1415+
this.emit(Events.OVERLAP, collisionInfo, body1.gameObject, body2.gameObject);
14211416
}
14221417
}
14231418
else if (body1.onCollide || body2.onCollide)
14241419
{
1425-
this.emit(Events.COLLIDE, body1.gameObject, body2.gameObject, body1, body2);
1420+
this.emit(Events.COLLIDE, collisionInfo, body1.gameObject, body2.gameObject);
14261421
}
14271422
}
1423+
else if (collisionInfo.touching && (body1.onTouch || body2.onTouch))
1424+
{
1425+
this.emit(Events.TOUCH, collisionInfo, body1.gameObject, body2.gameObject);
1426+
}
14281427

1429-
return result;
1428+
return collisionInfo.intersects;
14301429
},
14311430

14321431
/**

0 commit comments

Comments
 (0)