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.shouldRemove) {
    component.receiveDamage(attackFrom, damage, id);
  } else if (!withDecorationCollision) {
    return false;
  }
  _destroyObject();
  return true;
}