mirror of https://github.com/flutter/pinball.git
parent
d1f2e56912
commit
d92867311f
@ -0,0 +1,48 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flame/extensions.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||||
|
|
||||||
|
class SparkyBumperGame extends BasicBallGame {
|
||||||
|
SparkyBumperGame({
|
||||||
|
required this.trace,
|
||||||
|
}) : super(color: const Color(0xFF0000FF));
|
||||||
|
|
||||||
|
static const info = '''
|
||||||
|
Shows how a SparkyBumper is rendered.
|
||||||
|
|
||||||
|
Activate the "trace" parameter to overlay the body.
|
||||||
|
''';
|
||||||
|
|
||||||
|
final bool trace;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
final center = screenToWorld(camera.viewport.canvasSize! / 2);
|
||||||
|
final sparkyBumperA = SparkyBumper.a()
|
||||||
|
..initialPosition = Vector2(center.x - 20, center.y - 20)
|
||||||
|
..priority = 1;
|
||||||
|
final sparkyBumperB = SparkyBumper.b()
|
||||||
|
..initialPosition = Vector2(center.x - 10, center.y + 10)
|
||||||
|
..priority = 1;
|
||||||
|
final sparkyBumperC = SparkyBumper.c()
|
||||||
|
..initialPosition = Vector2(center.x + 20, center.y)
|
||||||
|
..priority = 1;
|
||||||
|
await addAll([
|
||||||
|
sparkyBumperA,
|
||||||
|
sparkyBumperB,
|
||||||
|
sparkyBumperC,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (trace) {
|
||||||
|
sparkyBumperA.trace();
|
||||||
|
sparkyBumperB.trace();
|
||||||
|
sparkyBumperC.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/sparky_bumper/sparky_bumper_game.dart';
|
||||||
|
|
||||||
|
void addSparkyBumperStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Sparky Bumpers').add(
|
||||||
|
'Basic',
|
||||||
|
(context) => GameWidget(
|
||||||
|
game: SparkyBumperGame(
|
||||||
|
trace: context.boolProperty('Trace', true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
codeLink: buildSourceLink('sparky_bumper/basic.dart'),
|
||||||
|
info: SparkyBumperGame.info,
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in new issue