From d7583cc76c3124a7f5f928563d7a4990e8bc638f Mon Sep 17 00:00:00 2001 From: alestiago Date: Thu, 7 Apr 2022 13:27:56 +0100 Subject: [PATCH] refacto: adjusted anchoring points --- lib/game/components/plunger.dart | 6 +++--- .../lib/src/components/chrome_dino.dart | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/game/components/plunger.dart b/lib/game/components/plunger.dart index b319af80..1911be02 100644 --- a/lib/game/components/plunger.dart +++ b/lib/game/components/plunger.dart @@ -129,8 +129,8 @@ class PlungerAnchor extends JointAnchor { required Plunger plunger, }) { initialPosition = Vector2( - plunger.body.position.x, - plunger.body.position.y - plunger.compressionDistance, + 0, + -plunger.compressionDistance, ); } @@ -161,7 +161,7 @@ class PlungerAnchorPrismaticJointDef extends PrismaticJointDef { initialize( plunger.body, anchor.body, - anchor.body.position, + plunger.body.position + anchor.body.position, Vector2(18.6, BoardDimensions.bounds.height), ); enableLimit = true; diff --git a/packages/pinball_components/lib/src/components/chrome_dino.dart b/packages/pinball_components/lib/src/components/chrome_dino.dart index 2caa40c8..327e14f5 100644 --- a/packages/pinball_components/lib/src/components/chrome_dino.dart +++ b/packages/pinball_components/lib/src/components/chrome_dino.dart @@ -23,7 +23,7 @@ class ChromeDino extends BodyComponent with InitialPosition { /// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc /// motion. Future<_ChromeDinoJoint> _anchorToJoint() async { - final anchor = _ChromeDinoAnchor(chromeDino: this); + final anchor = _ChromeDinoAnchor(); await add(anchor); final jointDef = _ChromeDinoAnchorRevoluteJointDef( @@ -110,12 +110,10 @@ class ChromeDino extends BodyComponent with InitialPosition { /// {@endtemplate} class _ChromeDinoAnchor extends JointAnchor { /// {@macro flipper_anchor} - _ChromeDinoAnchor({ - required ChromeDino chromeDino, - }) { + _ChromeDinoAnchor() { initialPosition = Vector2( - chromeDino.body.position.x + ChromeDino.size.x / 2, - chromeDino.body.position.y, + ChromeDino.size.x / 2, + 0, ); } } @@ -132,7 +130,7 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef { initialize( chromeDino.body, anchor.body, - anchor.body.position, + chromeDino.body.position + anchor.body.position, ); enableLimit = true; // TODO(alestiago): Apply design angle value.