onCollision method

  1. @override
void onCollision(
  1. Set<Vector2> intersectionPoints,
  2. PositionComponent other
)
override

onCollision is called in every tick when this object is colliding with other.

Implementation

@override
void onCollision(Set<Vector2> intersectionPoints, PositionComponent other) {
  if (other is Attackable) {
    if (!other.checkCanReceiveDamage(attackFrom)) {
      return;
    }

    if (animationDestroy == null) {
      other.handleAttack(attackFrom, damage, id);
    }
  }

  _destroyObject();
  super.onCollision(intersectionPoints, other);
}