onCollision method

  1. @override
bool onCollision(
  1. GameComponent component,
  2. bool active
)
override

if return false so the object will not collide with anything or block the passage.

Implementation

@override
bool onCollision(GameComponent component, bool active) {
  if (component is Attackable && !component.isRemoving) {
    if (component.checkCanReceiveDamage(attackFrom)) {
      return true;
    } else {
      return false;
    }
  } else if (!withDecorationCollision) {
    return false;
  }
  return true;
}