prepare method

  1. @override
  2. @mustCallSuper
void prepare(
  1. Component component
)
override

Prepares the Component to be added to a parent, and if there is an ancestor that is a FlameGame that game will do necessary preparations for this component. If there are no parents that are a Game false will be returned and this will run again once an ancestor or the component itself is added to a Game.

Implementation

@override
@mustCallSuper
void prepare(Component component) {
  super.prepare(component);
  if (isPrepared) {
    final parentGame = findParent<FlameGame>();
    assert(
      parentGame is HasHoverables,
      'Hoverable Components can only be added to a FlameGame with '
      'HasHoverables',
    );
  }
}