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
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();
gameRef.addContactCallback(_DashNestBumperBallContactCallback());
final signPost = FlutterSignPost()..initialPosition = Vector2(8.35, -58.3);
final signPost = SignPost()..initialPosition = Vector2(8.35, -58.3);
final bigNest = _BigDashNestBumper()
..initialPosition = Vector2(18.55, -59.35);

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

@ -67,7 +67,7 @@ abstract class RenderPriority {
// Flutter Forest
static const int flutterSignPost = _above + launchRampForegroundRailing;
static const int signPost = _above + launchRampForegroundRailing;
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.
/// {@endtemplate}
class FlutterSignPost extends BodyComponent with InitialPosition {
/// {@macro flutter_sign_post}
FlutterSignPost()
class SignPost extends BodyComponent with InitialPosition {
/// {@macro sign_post}
SignPost()
: super(
priority: RenderPriority.flutterSignPost,
children: [_FlutterSignPostSpriteComponent()],
priority: RenderPriority.signPost,
children: [_SignPostSpriteComponent()],
) {
renderBody = false;
}
@ -45,7 +45,7 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
/// Forwards the sprite to the next [_SignPostSpriteState].
///
/// 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
Body createBody() {
@ -59,9 +59,9 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
}
}
class _FlutterSignPostSpriteComponent
class _SignPostSpriteComponent
extends SpriteGroupComponent<_SignPostSpriteState> with HasGameRef {
_FlutterSignPostSpriteComponent()
_SignPostSpriteComponent()
: super(
anchor: Anchor.bottomCenter,
position: Vector2(0.65, 0.45),

@ -1,14 +1,13 @@
import 'dart:async';
import 'package:flame/input.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 FlutterSignPostGame extends BasicBallGame with Traceable, TapDetector {
class SignPostGame extends BasicBallGame with Traceable, TapDetector {
static const info = '''
Shows how a FlutterSignPost is rendered.
Shows how a SignPost is rendered.
- Activate the "trace" parameter to overlay the body.
- Tap to progress the sprite.
@ -26,13 +25,13 @@ class FlutterSignPostGame extends BasicBallGame with Traceable, TapDetector {
]);
camera.followVector2(Vector2.zero());
await add(FlutterSignPost()..priority = 1);
await add(SignPost()..priority = 1);
await traceAllBodies();
}
@override
void 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:sandbox/common/common.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_b_game.dart';
@ -11,11 +11,10 @@ void addDashNestBumperStories(Dashbook dashbook) {
..add(
'Flutter Sign Post',
(context) => GameWidget(
game: FlutterSignPostGame()
..trace = context.boolProperty('Trace', true),
game: SignPostGame()..trace = context.boolProperty('Trace', true),
),
codeLink: buildSourceLink('flutter_forest/flutter_sign_post.dart'),
info: FlutterSignPostGame.info,
codeLink: buildSourceLink('flutter_forest/sign_post.dart'),
info: SignPostGame.info,
)
..add(
'Big Dash Nest Bumper',

@ -14,7 +14,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
group('FlutterSignPost', () {
group('SignPost', () {
final assets = [
Assets.images.signPost.inactive.keyName,
Assets.images.signPost.active1.keyName,
@ -26,11 +26,11 @@ void main() {
'loads correctly',
(game) async {
await game.images.loadAll(assets);
final flutterSignPost = FlutterSignPost();
final signPost = SignPost();
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',
setUp: (game, tester) async {
await game.images.loadAll(assets);
await game.ensureAdd(FlutterSignPost());
await game.ensureAdd(SignPost());
game.camera.followVector2(Vector2.zero());
},
verify: (game, tester) async {
await expectLater(
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 {
await game.images.loadAll(assets);
final signPost = FlutterSignPost();
final signPost = SignPost();
await game.ensureAdd(signPost);
signPost.progress();
@ -64,7 +64,7 @@ void main() {
verify: (game, tester) async {
await expectLater(
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 {
await game.images.loadAll(assets);
final signPost = FlutterSignPost();
final signPost = SignPost();
await game.ensureAdd(signPost);
signPost
..progress()
@ -85,7 +85,7 @@ void main() {
verify: (game, tester) async {
await expectLater(
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 {
await game.images.loadAll(assets);
final signPost = FlutterSignPost();
final signPost = SignPost();
await game.ensureAdd(signPost);
signPost
..progress()
@ -107,7 +107,7 @@ void main() {
verify: (game, tester) async {
await expectLater(
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',
(game) async {
await game.images.loadAll(assets);
final flutterSignPost = FlutterSignPost();
final signPost = SignPost();
await game.ready();
await game.ensureAdd(flutterSignPost);
await game.ensureAdd(signPost);
final spriteComponent =
flutterSignPost.firstChild<SpriteGroupComponent>()!;
final spriteComponent = signPost.firstChild<SpriteGroupComponent>()!;
final sprites = <Sprite>{};
for (var i = 0; i < 4; i++) {
sprites.add(spriteComponent.sprite!);
flutterSignPost.progress();
signPost.progress();
}
expect(sprites.length, equals(4));

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

Loading…
Cancel
Save