onRemove method

  1. @override
void onRemove()
override

Called right before the component is removed from the game.

Implementation

@override
void onRemove() {
  final parentGame = findParent<FlameGame>();
  if (parentGame is HasCollidables) {
    parentGame.collidables.remove(this);
  }
  super.onRemove();
}