mirror of https://github.com/flutter/pinball.git
parent
daebb0b749
commit
3a89c101c0
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,42 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
static const info = '''
|
||||||
|
Shows how Boundaries are rendered.
|
||||||
|
|
||||||
|
- Activate the "trace" parameter to overlay the body.
|
||||||
|
- Tap anywhere on the screen to spawn a ball into the game.
|
||||||
|
''';
|
||||||
|
|
||||||
|
final bool trace;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
await addFromBlueprint(Boundaries());
|
||||||
|
await ready();
|
||||||
|
|
||||||
|
camera
|
||||||
|
..followVector2(Vector2.zero())
|
||||||
|
..zoom = 6;
|
||||||
|
|
||||||
|
final bottomBoundary = children.whereType<BodyComponent>().first;
|
||||||
|
final outerBoundary = children.whereType<BodyComponent>().last;
|
||||||
|
|
||||||
|
if (trace) {
|
||||||
|
bottomBoundary.trace();
|
||||||
|
outerBoundary.trace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/boundaries/boundaries_game.dart';
|
||||||
|
|
||||||
|
void addBoundariesStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Boundaries').add(
|
||||||
|
'Basic',
|
||||||
|
(context) => GameWidget(
|
||||||
|
game: BoundariesGame(
|
||||||
|
trace: context.boolProperty('Trace', true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
codeLink: buildSourceLink('boundaries_game/basic.dart'),
|
||||||
|
info: BoundariesGame.info,
|
||||||
|
);
|
||||||
|
}
|
Before Width: | Height: | Size: 324 KiB After Width: | Height: | Size: 153 KiB |
Loading…
Reference in new issue