mirror of https://github.com/flutter/pinball.git
parent
59ea135133
commit
b15517a56d
@ -0,0 +1,33 @@
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||
|
||||
class PlungerGame extends BasicBallGame with HasKeyboardHandlerComponents {
|
||||
PlungerGame({
|
||||
required this.trace,
|
||||
}) : super(color: const Color(0xFFFF0000));
|
||||
|
||||
static const info = '''
|
||||
Shows how Plunger is 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();
|
||||
|
||||
final center = screenToWorld(camera.viewport.canvasSize! / 2);
|
||||
|
||||
final plunger = Plunger(compressionDistance: 29)
|
||||
..initialPosition = Vector2(center.x - (Kicker.size.x * 2), center.y);
|
||||
await add(plunger);
|
||||
|
||||
if (trace) plunger.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/plunger/plunger_game.dart';
|
||||
|
||||
void addPlungerStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('Plunger').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: PlungerGame(
|
||||
trace: context.boolProperty('Trace', true),
|
||||
),
|
||||
),
|
||||
codeLink: buildSourceLink('plunger_game/basic.dart'),
|
||||
info: PlungerGame.info,
|
||||
);
|
||||
}
|
Loading…
Reference in new issue