refacto: adjusted anchoring points

pull/159/head
alestiago 4 years ago
parent 1ae00bebf0
commit d7583cc76c

@ -129,8 +129,8 @@ class PlungerAnchor extends JointAnchor {
required Plunger plunger, required Plunger plunger,
}) { }) {
initialPosition = Vector2( initialPosition = Vector2(
plunger.body.position.x, 0,
plunger.body.position.y - plunger.compressionDistance, -plunger.compressionDistance,
); );
} }
@ -161,7 +161,7 @@ class PlungerAnchorPrismaticJointDef extends PrismaticJointDef {
initialize( initialize(
plunger.body, plunger.body,
anchor.body, anchor.body,
anchor.body.position, plunger.body.position + anchor.body.position,
Vector2(18.6, BoardDimensions.bounds.height), Vector2(18.6, BoardDimensions.bounds.height),
); );
enableLimit = true; enableLimit = true;

@ -23,7 +23,7 @@ class ChromeDino extends BodyComponent with InitialPosition {
/// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc /// Anchors the [ChromeDino] to the [RevoluteJoint] that controls its arc
/// motion. /// motion.
Future<_ChromeDinoJoint> _anchorToJoint() async { Future<_ChromeDinoJoint> _anchorToJoint() async {
final anchor = _ChromeDinoAnchor(chromeDino: this); final anchor = _ChromeDinoAnchor();
await add(anchor); await add(anchor);
final jointDef = _ChromeDinoAnchorRevoluteJointDef( final jointDef = _ChromeDinoAnchorRevoluteJointDef(
@ -110,12 +110,10 @@ class ChromeDino extends BodyComponent with InitialPosition {
/// {@endtemplate} /// {@endtemplate}
class _ChromeDinoAnchor extends JointAnchor { class _ChromeDinoAnchor extends JointAnchor {
/// {@macro flipper_anchor} /// {@macro flipper_anchor}
_ChromeDinoAnchor({ _ChromeDinoAnchor() {
required ChromeDino chromeDino,
}) {
initialPosition = Vector2( initialPosition = Vector2(
chromeDino.body.position.x + ChromeDino.size.x / 2, ChromeDino.size.x / 2,
chromeDino.body.position.y, 0,
); );
} }
} }
@ -132,7 +130,7 @@ class _ChromeDinoAnchorRevoluteJointDef extends RevoluteJointDef {
initialize( initialize(
chromeDino.body, chromeDino.body,
anchor.body, anchor.body,
anchor.body.position, chromeDino.body.position + anchor.body.position,
); );
enableLimit = true; enableLimit = true;
// TODO(alestiago): Apply design angle value. // TODO(alestiago): Apply design angle value.

Loading…
Cancel
Save