refactor: plunger spritecomponent

pull/152/head
RuiAlonso 4 years ago
parent a7dd1c2a2d
commit 059c76af20

@ -14,9 +14,7 @@ class Plunger extends BodyComponent with InitialPosition {
required this.compressionDistance, required this.compressionDistance,
// TODO(ruimiguel): set to priority +1 over LaunchRamp once all priorities // TODO(ruimiguel): set to priority +1 over LaunchRamp once all priorities
// are fixed. // are fixed.
}) : super(priority: 0) { }) : super(priority: 0);
renderBody = false;
}
/// Distance the plunger can lower. /// Distance the plunger can lower.
final double compressionDistance; final double compressionDistance;
@ -76,23 +74,23 @@ class Plunger extends BodyComponent with InitialPosition {
Future<void> onLoad() async { Future<void> onLoad() async {
await super.onLoad(); await super.onLoad();
await _anchorToJoint(); await _anchorToJoint();
await _loadSprite(); await add(_PlungerSpriteComponent());
}
} }
Future<void> _loadSprite() async { class _PlungerSpriteComponent extends SpriteComponent with HasGameRef {
@override
Future<void> onLoad() async {
await super.onLoad();
final sprite = await gameRef.loadSprite( final sprite = await gameRef.loadSprite(
Assets.images.plunger.plunger.keyName, Assets.images.plunger.plunger.keyName,
); );
await add( this.sprite = sprite;
SpriteComponent( size = Vector2(5.5, 40);
sprite: sprite, anchor = Anchor.center;
size: Vector2(5.5, 40), position = Vector2(2, 19);
anchor: Anchor.center, angle = -0.033;
position: Vector2(2, 19),
angle: -0.033,
),
);
} }
} }

Loading…
Cancel
Save