feat: renamed FlutterSignPost to SignPost

pull/205/head
alestiago 3 years ago
parent 36bce4ad99
commit 0c832be547

3
.gitignore vendored

@ -131,6 +131,3 @@ app.*.map.json
test/.test_runner.dart test/.test_runner.dart
web/__/firebase/init.js web/__/firebase/init.js
# Application exceptions
!/packages/pinball_components/assets/images/flutter_sign_post.png

@ -25,7 +25,7 @@ class FlutterForest extends Component
await super.onLoad(); await super.onLoad();
gameRef.addContactCallback(_DashNestBumperBallContactCallback()); gameRef.addContactCallback(_DashNestBumperBallContactCallback());
final signPost = FlutterSignPost()..initialPosition = Vector2(8.35, -58.3); final signPost = SignPost()..initialPosition = Vector2(8.35, -58.3);
final bigNest = _BigDashNestBumper() final bigNest = _BigDashNestBumper()
..initialPosition = Vector2(18.55, -59.35); ..initialPosition = Vector2(18.55, -59.35);

@ -12,7 +12,6 @@ export 'dash_nest_bumper.dart';
export 'dino_walls.dart'; export 'dino_walls.dart';
export 'fire_effect.dart'; export 'fire_effect.dart';
export 'flipper.dart'; export 'flipper.dart';
export 'flutter_sign_post.dart';
export 'google_letter.dart'; export 'google_letter.dart';
export 'initial_position.dart'; export 'initial_position.dart';
export 'joint_anchor.dart'; export 'joint_anchor.dart';
@ -25,6 +24,7 @@ export 'render_priority.dart';
export 'rocket.dart'; export 'rocket.dart';
export 'score_text.dart'; export 'score_text.dart';
export 'shapes/shapes.dart'; export 'shapes/shapes.dart';
export 'sign_post.dart';
export 'slingshot.dart'; export 'slingshot.dart';
export 'spaceship.dart'; export 'spaceship.dart';
export 'spaceship_rail.dart'; export 'spaceship_rail.dart';

@ -67,7 +67,7 @@ abstract class RenderPriority {
// Flutter Forest // Flutter Forest
static const int flutterSignPost = _above + launchRampForegroundRailing; static const int signPost = _above + launchRampForegroundRailing;
static const int dashBumper = _above + ballOnBoard; static const int dashBumper = _above + ballOnBoard;

@ -29,15 +29,15 @@ extension on _SignPostSpriteState {
} }
} }
/// {@template flutter_sign_post} /// {@template sign_post}
/// A sign, found in the Flutter Forest. /// A sign, found in the Flutter Forest.
/// {@endtemplate} /// {@endtemplate}
class FlutterSignPost extends BodyComponent with InitialPosition { class SignPost extends BodyComponent with InitialPosition {
/// {@macro flutter_sign_post} /// {@macro sign_post}
FlutterSignPost() SignPost()
: super( : super(
priority: RenderPriority.flutterSignPost, priority: RenderPriority.signPost,
children: [_FlutterSignPostSpriteComponent()], children: [_SignPostSpriteComponent()],
) { ) {
renderBody = false; renderBody = false;
} }
@ -45,7 +45,7 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
/// Forwards the sprite to the next [_SignPostSpriteState]. /// Forwards the sprite to the next [_SignPostSpriteState].
/// ///
/// If the current state is the last one it goes back to the initial state. /// If the current state is the last one it goes back to the initial state.
void progress() => firstChild<_FlutterSignPostSpriteComponent>()!.progress(); void progress() => firstChild<_SignPostSpriteComponent>()!.progress();
@override @override
Body createBody() { Body createBody() {
@ -59,9 +59,9 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
} }
} }
class _FlutterSignPostSpriteComponent class _SignPostSpriteComponent
extends SpriteGroupComponent<_SignPostSpriteState> with HasGameRef { extends SpriteGroupComponent<_SignPostSpriteState> with HasGameRef {
_FlutterSignPostSpriteComponent() _SignPostSpriteComponent()
: super( : super(
anchor: Anchor.bottomCenter, anchor: Anchor.bottomCenter,
position: Vector2(0.65, 0.45), position: Vector2(0.65, 0.45),

@ -1,14 +1,13 @@
import 'dart:async'; import 'dart:async';
import 'package:flame/input.dart'; import 'package:flame/input.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart'; import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart'; import 'package:sandbox/stories/ball/basic_ball_game.dart';
class FlutterSignPostGame extends BasicBallGame with Traceable, TapDetector { class SignPostGame extends BasicBallGame with Traceable, TapDetector {
static const info = ''' static const info = '''
Shows how a FlutterSignPost is rendered. Shows how a SignPost is rendered.
- Activate the "trace" parameter to overlay the body. - Activate the "trace" parameter to overlay the body.
- Tap to progress the sprite. - Tap to progress the sprite.
@ -26,13 +25,13 @@ class FlutterSignPostGame extends BasicBallGame with Traceable, TapDetector {
]); ]);
camera.followVector2(Vector2.zero()); camera.followVector2(Vector2.zero());
await add(FlutterSignPost()..priority = 1); await add(SignPost()..priority = 1);
await traceAllBodies(); await traceAllBodies();
} }
@override @override
void onTap() { void onTap() {
super.onTap(); super.onTap();
firstChild<FlutterSignPost>()!.progress(); firstChild<SignPost>()!.progress();
} }
} }

@ -2,7 +2,7 @@ import 'package:dashbook/dashbook.dart';
import 'package:flame/game.dart'; import 'package:flame/game.dart';
import 'package:sandbox/common/common.dart'; import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/flutter_forest/big_dash_nest_bumper_game.dart'; import 'package:sandbox/stories/flutter_forest/big_dash_nest_bumper_game.dart';
import 'package:sandbox/stories/flutter_forest/flutter_sign_post_game.dart'; import 'package:sandbox/stories/flutter_forest/sign_post_game.dart';
import 'package:sandbox/stories/flutter_forest/small_dash_nest_bumper_a_game.dart'; import 'package:sandbox/stories/flutter_forest/small_dash_nest_bumper_a_game.dart';
import 'package:sandbox/stories/flutter_forest/small_dash_nest_bumper_b_game.dart'; import 'package:sandbox/stories/flutter_forest/small_dash_nest_bumper_b_game.dart';
@ -11,11 +11,10 @@ void addDashNestBumperStories(Dashbook dashbook) {
..add( ..add(
'Flutter Sign Post', 'Flutter Sign Post',
(context) => GameWidget( (context) => GameWidget(
game: FlutterSignPostGame() game: SignPostGame()..trace = context.boolProperty('Trace', true),
..trace = context.boolProperty('Trace', true),
), ),
codeLink: buildSourceLink('flutter_forest/flutter_sign_post.dart'), codeLink: buildSourceLink('flutter_forest/sign_post.dart'),
info: FlutterSignPostGame.info, info: SignPostGame.info,
) )
..add( ..add(
'Big Dash Nest Bumper', 'Big Dash Nest Bumper',

@ -14,7 +14,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new); final flameTester = FlameTester(TestGame.new);
group('FlutterSignPost', () { group('SignPost', () {
final assets = [ final assets = [
Assets.images.signPost.inactive.keyName, Assets.images.signPost.inactive.keyName,
Assets.images.signPost.active1.keyName, Assets.images.signPost.active1.keyName,
@ -26,11 +26,11 @@ void main() {
'loads correctly', 'loads correctly',
(game) async { (game) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
final flutterSignPost = FlutterSignPost(); final signPost = SignPost();
await game.ready(); await game.ready();
await game.ensureAdd(flutterSignPost); await game.ensureAdd(signPost);
expect(game.contains(flutterSignPost), isTrue); expect(game.contains(signPost), isTrue);
}, },
); );
@ -39,13 +39,13 @@ void main() {
'inactive sprite', 'inactive sprite',
setUp: (game, tester) async { setUp: (game, tester) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
await game.ensureAdd(FlutterSignPost()); await game.ensureAdd(SignPost());
game.camera.followVector2(Vector2.zero()); game.camera.followVector2(Vector2.zero());
}, },
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/flutter-sign-post__inactive.png'), matchesGoldenFile('golden/sign-post__inactive.png'),
); );
}, },
); );
@ -55,7 +55,7 @@ void main() {
setUp: (game, tester) async { setUp: (game, tester) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
final signPost = FlutterSignPost(); final signPost = SignPost();
await game.ensureAdd(signPost); await game.ensureAdd(signPost);
signPost.progress(); signPost.progress();
@ -64,7 +64,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/flutter-sign-post__active1.png'), matchesGoldenFile('golden/sign-post__active1.png'),
); );
}, },
); );
@ -74,7 +74,7 @@ void main() {
setUp: (game, tester) async { setUp: (game, tester) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
final signPost = FlutterSignPost(); final signPost = SignPost();
await game.ensureAdd(signPost); await game.ensureAdd(signPost);
signPost signPost
..progress() ..progress()
@ -85,7 +85,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/flutter-sign-post__active2.png'), matchesGoldenFile('golden/sign-post__active2.png'),
); );
}, },
); );
@ -95,7 +95,7 @@ void main() {
setUp: (game, tester) async { setUp: (game, tester) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
final signPost = FlutterSignPost(); final signPost = SignPost();
await game.ensureAdd(signPost); await game.ensureAdd(signPost);
signPost signPost
..progress() ..progress()
@ -107,7 +107,7 @@ void main() {
verify: (game, tester) async { verify: (game, tester) async {
await expectLater( await expectLater(
find.byGame<TestGame>(), find.byGame<TestGame>(),
matchesGoldenFile('golden/flutter-sign-post__active3.png'), matchesGoldenFile('golden/sign-post__active3.png'),
); );
}, },
); );
@ -117,17 +117,16 @@ void main() {
'progress changes correctly between four sprites', 'progress changes correctly between four sprites',
(game) async { (game) async {
await game.images.loadAll(assets); await game.images.loadAll(assets);
final flutterSignPost = FlutterSignPost(); final signPost = SignPost();
await game.ready(); await game.ready();
await game.ensureAdd(flutterSignPost); await game.ensureAdd(signPost);
final spriteComponent = final spriteComponent = signPost.firstChild<SpriteGroupComponent>()!;
flutterSignPost.firstChild<SpriteGroupComponent>()!;
final sprites = <Sprite>{}; final sprites = <Sprite>{};
for (var i = 0; i < 4; i++) { for (var i = 0; i < 4; i++) {
sprites.add(spriteComponent.sprite!); sprites.add(spriteComponent.sprite!);
flutterSignPost.progress(); signPost.progress();
} }
expect(sprites.length, equals(4)); expect(sprites.length, equals(4));

@ -27,13 +27,13 @@ void main() {
group('loads', () { group('loads', () {
flameTester.test( flameTester.test(
'a FlutterSignPost', 'a SignPost',
(game) async { (game) async {
final flutterForest = FlutterForest(); final flutterForest = FlutterForest();
await game.ensureAdd(flutterForest); await game.ensureAdd(flutterForest);
expect( expect(
flutterForest.descendants().whereType<FlutterSignPost>().length, flutterForest.descendants().whereType<SignPost>().length,
equals(1), equals(1),
); );
}, },

Loading…
Cancel
Save