|
|
|
@ -58,11 +58,8 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
|
|
|
|
|
/// Sprite is preloaded by [PinballGameAssetsX].
|
|
|
|
|
static const spritePath = 'components/flipper.png';
|
|
|
|
|
|
|
|
|
|
/// The width of the [Flipper].
|
|
|
|
|
static const width = 12.0;
|
|
|
|
|
|
|
|
|
|
/// The height of the [Flipper].
|
|
|
|
|
static const height = 2.8;
|
|
|
|
|
/// The size of the [Flipper].
|
|
|
|
|
static final size = Vector2(12, 2.8);
|
|
|
|
|
|
|
|
|
|
/// The speed required to move the [Flipper] to its highest position.
|
|
|
|
|
///
|
|
|
|
@ -97,7 +94,7 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
|
|
|
|
|
final sprite = await gameRef.loadSprite(spritePath);
|
|
|
|
|
final spriteComponent = SpriteComponent(
|
|
|
|
|
sprite: sprite,
|
|
|
|
|
size: Vector2(width, height),
|
|
|
|
|
size: size,
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -134,21 +131,21 @@ class Flipper extends BodyComponent with KeyboardHandler, InitialPosition {
|
|
|
|
|
final fixturesDef = <FixtureDef>[];
|
|
|
|
|
final isLeft = side.isLeft;
|
|
|
|
|
|
|
|
|
|
final bigCircleShape = CircleShape()..radius = height / 2;
|
|
|
|
|
final bigCircleShape = CircleShape()..radius = 1.75;
|
|
|
|
|
bigCircleShape.position.setValues(
|
|
|
|
|
isLeft
|
|
|
|
|
? -(width / 2) + bigCircleShape.radius
|
|
|
|
|
: (width / 2) - bigCircleShape.radius,
|
|
|
|
|
? -(size.x / 2) + bigCircleShape.radius
|
|
|
|
|
: (size.x / 2) - bigCircleShape.radius,
|
|
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
final bigCircleFixtureDef = FixtureDef(bigCircleShape);
|
|
|
|
|
fixturesDef.add(bigCircleFixtureDef);
|
|
|
|
|
|
|
|
|
|
final smallCircleShape = CircleShape()..radius = bigCircleShape.radius / 2;
|
|
|
|
|
final smallCircleShape = CircleShape()..radius = 0.9;
|
|
|
|
|
smallCircleShape.position.setValues(
|
|
|
|
|
isLeft
|
|
|
|
|
? (width / 2) - smallCircleShape.radius
|
|
|
|
|
: -(width / 2) + smallCircleShape.radius,
|
|
|
|
|
? (size.x / 2) - smallCircleShape.radius
|
|
|
|
|
: -(size.x / 2) + smallCircleShape.radius,
|
|
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
final smallCircleFixtureDef = FixtureDef(smallCircleShape);
|
|
|
|
@ -227,8 +224,8 @@ class FlipperAnchor extends JointAnchor {
|
|
|
|
|
}) {
|
|
|
|
|
initialPosition = Vector2(
|
|
|
|
|
flipper.side.isLeft
|
|
|
|
|
? flipper.body.position.x - Flipper.width / 2
|
|
|
|
|
: flipper.body.position.x + Flipper.width / 2,
|
|
|
|
|
? flipper.body.position.x - Flipper.size.x / 2
|
|
|
|
|
: flipper.body.position.x + Flipper.size.x / 2,
|
|
|
|
|
flipper.body.position.y,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|