FlameGame<W extends World> constructor

FlameGame<W extends World>({
  1. Iterable<Component>? children,
  2. W? world,
  3. CameraComponent? camera,
})

Implementation

FlameGame({
  super.children,
  W? world,
  CameraComponent? camera,
})  : assert(
        world != null || W == World,
        'The generics type $W does not conform to the type of '
        '${world?.runtimeType ?? 'World'}.',
      ),
      _world = world ?? World() as W,
      _camera = camera ?? CameraComponent() {
  assert(
    Component.staticGameInstance == null,
    '$this instantiated, while another game ${Component.staticGameInstance} '
    'declares itself to be a singleton',
  );

  if (kDebugMode) {
    DevToolsService.initWithGame(this);
  }

  _camera.world = _world;
  add(_camera);
  add(_world);
}