diff --git a/packages/pinball_components/lib/src/components/flutter_sign_post.dart b/packages/pinball_components/lib/src/components/flutter_sign_post.dart index deaceb76..e44f11ac 100644 --- a/packages/pinball_components/lib/src/components/flutter_sign_post.dart +++ b/packages/pinball_components/lib/src/components/flutter_sign_post.dart @@ -4,30 +4,15 @@ import 'package:flutter/material.dart'; import 'package:pinball_components/pinball_components.dart'; /// {@template flutter_sign_post} -/// A sign, found in the FlutterForest. +/// 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 _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 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 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); + } +}