SpawnComponent constructor
SpawnComponent({
- required PositionComponent factory(
- int amount
- required double period,
- Shape? area,
- bool within = true,
- bool selfPositioning = false,
- bool autoStart = true,
- bool spawnWhenLoaded = false,
- Random? random,
- ComponentKey? key,
The SpawnComponent is a non-visual component which can spawn
PositionComponents randomly within a set area. If area is not set it
will use the size of the nearest ancestor that provides a size.
period
will set the static time interval for when it will spawn new
components.
If you want to use a non static time interval, use the
SpawnComponent.periodRange constructor.
If you want to set the position of the spawned components yourself inside of
the factory, set selfPositioning to true.
Implementation
SpawnComponent({
required this.factory,
required double period,
this.area,
this.within = true,
this.selfPositioning = false,
this.autoStart = true,
this.spawnWhenLoaded = false,
Random? random,
super.key,
}) : assert(
!(selfPositioning && area != null),
"Don't set an area when you are using selfPositioning=true",
),
_period = period,
_random = random ?? randomFallback;