prepare method
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 parent) {
super.prepare(parent);
if (isPrepared) {
final parentGame = findParent<FlameGame>();
assert(
parentGame is HasCollidables,
'You can only use the HasHitboxes/Collidable feature with games that '
'has the HasCollidables mixin',
);
}
}