refactor: remove ballSize

pull/25/head
Allison Ryan 4 years ago
parent 6cbda5bac3
commit f2c55a8ecd

@ -12,11 +12,8 @@ class Ball extends PositionBodyComponent<PinballGame, SpriteComponent>
/// {@macro ball}
Ball({
required Vector2 position,
}) : _position = Vector2(position.x, position.y + ballSize.y),
super(size: ballSize);
/// Dimensions of the [Ball].
static final ballSize = Vector2.all(2);
}) : _position = position,
super(size: Vector2.all(2));
/// The initial position of the [Ball] body.
final Vector2 _position;
@ -41,7 +38,7 @@ class Ball extends PositionBodyComponent<PinballGame, SpriteComponent>
final bodyDef = BodyDef()
..userData = this
..position = _position
..position = Vector2(_position.x, _position.y + size.y)
..type = BodyType.dynamic;
return world.createBody(bodyDef)..createFixture(fixtureDef);

@ -36,7 +36,7 @@ void main() {
final expectedPosition = Vector2(
position.x,
position.y + Ball.ballSize.y,
position.y + ball.size.y,
);
expect(ball.body.position, equals(expectedPosition));
},

Loading…
Cancel
Save