refactor: use Traceable

pull/156/head
Allison Ryan 4 years ago
parent 31e913ab1b
commit 63526b7753

@ -1,13 +1,10 @@
import 'package:flame/extensions.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart';
class BoundariesGame extends BasicBallGame {
BoundariesGame({
required this.trace,
}) : super(color: const Color(0xFFFF0000));
class BoundariesGame extends BasicBallGame with Traceable {
BoundariesGame() : super(color: const Color(0xFFFF0000));
static const info = '''
Shows how Boundaries are rendered.
@ -16,8 +13,6 @@ class BoundariesGame extends BasicBallGame {
- Tap anywhere on the screen to spawn a ball into the game.
''';
final bool trace;
@override
Future<void> onLoad() async {
await super.onLoad();
@ -29,12 +24,6 @@ class BoundariesGame extends BasicBallGame {
..followVector2(Vector2.zero())
..zoom = 6;
final bottomBoundary = children.whereType<BodyComponent>().first;
final outerBoundary = children.whereType<BodyComponent>().last;
if (trace) {
bottomBoundary.trace();
outerBoundary.trace();
}
await traceAllBodies();
}
}

@ -7,9 +7,7 @@ void addBoundariesStories(Dashbook dashbook) {
dashbook.storiesOf('Boundaries').add(
'Basic',
(context) => GameWidget(
game: BoundariesGame(
trace: context.boolProperty('Trace', true),
),
game: BoundariesGame()..trace = context.boolProperty('Trace', true),
),
codeLink: buildSourceLink('boundaries_game/basic.dart'),
info: BoundariesGame.info,

Loading…
Cancel
Save