|
|
|
@ -6,28 +6,13 @@ import 'package:pinball_components/pinball_components.dart';
|
|
|
|
|
/// {@template flutter_sign_post}
|
|
|
|
|
/// A sign, found in the Flutter Forest.
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
// TODO(alestiago): Revisit doc comment if FlutterForest is moved to package.
|
|
|
|
|
class FlutterSignPost extends BodyComponent with InitialPosition {
|
|
|
|
|
Future<void> _loadSprite() async {
|
|
|
|
|
final sprite = await gameRef.loadSprite(
|
|
|
|
|
Assets.images.flutterSignPost.keyName,
|
|
|
|
|
);
|
|
|
|
|
final spriteComponent = SpriteComponent(
|
|
|
|
|
sprite: sprite,
|
|
|
|
|
size: sprite.originalSize / 10,
|
|
|
|
|
anchor: Anchor.bottomCenter,
|
|
|
|
|
position: Vector2(0.65, 0.45),
|
|
|
|
|
);
|
|
|
|
|
await add(spriteComponent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
paint = Paint()
|
|
|
|
|
..color = Colors.blue.withOpacity(0.5)
|
|
|
|
|
..style = PaintingStyle.fill;
|
|
|
|
|
await _loadSprite();
|
|
|
|
|
renderBody = false;
|
|
|
|
|
|
|
|
|
|
await add(_FlutterSignPostSprite());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@ -39,3 +24,18 @@ class FlutterSignPost extends BodyComponent with InitialPosition {
|
|
|
|
|
return world.createBody(bodyDef)..createFixture(fixtureDef);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _FlutterSignPostSprite extends SpriteComponent with HasGameRef {
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
|
|
|
|
|
|
final sprite = await gameRef.loadSprite(
|
|
|
|
|
Assets.images.flutterSignPost.keyName,
|
|
|
|
|
);
|
|
|
|
|
this.sprite = sprite;
|
|
|
|
|
size = sprite.originalSize / 10;
|
|
|
|
|
anchor = Anchor.bottomCenter;
|
|
|
|
|
position = Vector2(0.65, 0.45);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|