refactor: used children param

pull/194/head
alestiago 3 years ago
parent 225e4a380c
commit e0c2708257

@ -1,10 +1,10 @@
// ignore_for_file: avoid_renaming_method_parameters // ignore_for_file: avoid_renaming_method_parameters
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart';
/// {@template sparky_fire_zone} /// {@template sparky_fire_zone}
/// Area positioned at the top left of the [Board] where the [Ball] /// Area positioned at the top left of the [Board] where the [Ball]
@ -12,31 +12,26 @@ import 'package:pinball_flame/pinball_flame.dart';
/// ///
/// When a [Ball] hits [SparkyBumper]s, the bumper animates. /// When a [Ball] hits [SparkyBumper]s, the bumper animates.
/// {@endtemplate} /// {@endtemplate}
class SparkyFireZone extends Forge2DBlueprint { class SparkyFireZone extends Component with HasGameRef<Forge2DGame> {
@override /// {@macro sparky_fire_zone}
void build(Forge2DGame gameRef) { SparkyFireZone()
gameRef.addContactCallback(SparkyBumperBallContactCallback()); : super(
children: [
addBlueprint(SparkyComputer()); _SparkyBumper.a()..initialPosition = Vector2(-22.9, -41.65),
final sparkyTurboChargeSensor = SparkyTurboChargeSensor() _SparkyBumper.b()..initialPosition = Vector2(-21.25, -57.9),
..initialPosition = Vector2(-13, 49.8); _SparkyBumper.c()..initialPosition = Vector2(-3.3, -52.55),
final sparkyAnimatronic = SparkyAnimatronic() SparkyComputer(),
..position = Vector2(-13.8, -58.2); SparkyTurboChargeSensor()..initialPosition = Vector2(-13, -49.8),
SparkyAnimatronic()..position = Vector2(-13.8, -58.2),
final lowerLeftBumper = _SparkyBumper.a() ],
..initialPosition = Vector2(-22.9, -41.65); );
final upperLeftBumper = _SparkyBumper.b()
..initialPosition = Vector2(-21.25, -57.9);
final rightBumper = _SparkyBumper.c()
..initialPosition = Vector2(-3.3, -52.55);
addAll([ @override
lowerLeftBumper, Future<void> onLoad() async {
upperLeftBumper, await super.onLoad();
rightBumper, gameRef
sparkyAnimatronic, ..addContactCallback(SparkyBumperBallContactCallback())
sparkyTurboChargeSensor, ..addContactCallback(SparkyTurboChargeSensorBallContactCallback());
]);
} }
} }

Loading…
Cancel
Save