emitContactEvents method
void
emitContactEvents()
Implementation
void emitContactEvents() {
final hasBeginContact = hasAnyEventListener('beginContact');
final hasEndContact = hasAnyEventListener('endContact');
if (hasBeginContact || hasEndContact) {
bodyOverlapKeeper.getDiff(additions, removals);
}
if (hasBeginContact) {
for (int i = 0, l = additions.length; i < l; i += 2) {
beginContactEvent.bodyA = getBodyById(additions[i]);
beginContactEvent.bodyB = getBodyById(additions[i + 1]);
dispatchEvent(beginContactEvent);
}
beginContactEvent.bodyA = beginContactEvent.bodyB = null;
}
if (hasEndContact) {
for (int i = 0, l = removals.length; i < l; i += 2) {
endContactEvent.bodyA = getBodyById(removals[i]);
endContactEvent.bodyB = getBodyById(removals[i + 1]);
dispatchEvent(endContactEvent);
}
endContactEvent.bodyA = endContactEvent.bodyB = null;
}
additions.clear();
removals.clear();
final hasBeginShapeContact = hasAnyEventListener('beginShapeContact');
final hasEndShapeContact = hasAnyEventListener('endShapeContact');
if (hasBeginShapeContact || hasEndShapeContact) {
shapeOverlapKeeper.getDiff(additions, removals);
}
if (hasBeginShapeContact) {
for (int i = 0, l = additions.length; i < l; i += 2) {
final shapeA = getShapeById(additions[i]);
final shapeB = getShapeById(additions[i + 1]);
beginShapeContactEvent.shapeA = shapeA;
beginShapeContactEvent.shapeB = shapeB;
if (shapeA != null) beginShapeContactEvent.bodyA = shapeA.body;
if (shapeB != null) beginShapeContactEvent.bodyB = shapeB.body;
dispatchEvent(beginShapeContactEvent);
}
beginShapeContactEvent.bodyA =
beginShapeContactEvent.bodyB =
beginShapeContactEvent.shapeA =
beginShapeContactEvent.shapeB =
null;
}
if (hasEndShapeContact) {
for (int i = 0, l = removals.length; i < l; i += 2) {
final shapeA = getShapeById(removals[i]);
final shapeB = getShapeById(removals[i + 1]);
endShapeContactEvent.shapeA = shapeA;
endShapeContactEvent.shapeB = shapeB;
if (shapeA != null) endShapeContactEvent.bodyA = shapeA.body;
if (shapeB != null) endShapeContactEvent.bodyB = shapeB.body;
dispatchEvent(endShapeContactEvent);
}
endShapeContactEvent.bodyA =
endShapeContactEvent.bodyB =
endShapeContactEvent.shapeA =
endShapeContactEvent.shapeB =
null;
}
}