|
|
|
@ -42,7 +42,7 @@ class SpaceshipRamp extends Component {
|
|
|
|
|
_SpaceshipRampBackground(),
|
|
|
|
|
_SpaceshipRampBoardOpening()..initialPosition = Vector2(3.4, -39.5),
|
|
|
|
|
_SpaceshipRampForegroundRailing(),
|
|
|
|
|
_SpaceshipRampBase()..initialPosition = Vector2(3.4, -42.5),
|
|
|
|
|
SpaceshipRampBase()..initialPosition = Vector2(3.4, -42.5),
|
|
|
|
|
_SpaceshipRampBackgroundRailingSpriteComponent(),
|
|
|
|
|
SpaceshipRampArrowSpriteComponent(
|
|
|
|
|
current: bloc.state.hits,
|
|
|
|
@ -255,9 +255,14 @@ class _SpaceshipRampBoardOpening extends BodyComponent
|
|
|
|
|
_SpaceshipRampBoardOpeningSpriteComponent(),
|
|
|
|
|
LayerContactBehavior(layer: Layer.spaceshipEntranceRamp)
|
|
|
|
|
..applyTo(['inside']),
|
|
|
|
|
LayerContactBehavior(layer: Layer.board)..applyTo(['outside']),
|
|
|
|
|
ZIndexContactBehavior(zIndex: ZIndexes.ballOnBoard)
|
|
|
|
|
..applyTo(['outside']),
|
|
|
|
|
LayerContactBehavior(
|
|
|
|
|
layer: Layer.board,
|
|
|
|
|
onBegin: false,
|
|
|
|
|
)..applyTo(['outside']),
|
|
|
|
|
ZIndexContactBehavior(
|
|
|
|
|
zIndex: ZIndexes.ballOnBoard,
|
|
|
|
|
onBegin: false,
|
|
|
|
|
)..applyTo(['outside']),
|
|
|
|
|
ZIndexContactBehavior(zIndex: ZIndexes.ballOnSpaceshipRamp)
|
|
|
|
|
..applyTo(['middle', 'inside']),
|
|
|
|
|
],
|
|
|
|
@ -426,9 +431,19 @@ class _SpaceshipRampForegroundRailingSpriteComponent extends SpriteComponent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SpaceshipRampBase extends BodyComponent with Layered, InitialPosition {
|
|
|
|
|
_SpaceshipRampBase() : super(renderBody: false) {
|
|
|
|
|
layer = Layer.board;
|
|
|
|
|
@visibleForTesting
|
|
|
|
|
class SpaceshipRampBase extends BodyComponent
|
|
|
|
|
with InitialPosition, ContactCallbacks {
|
|
|
|
|
SpaceshipRampBase() : super(renderBody: false);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void preSolve(Object other, Contact contact, Manifold oldManifold) {
|
|
|
|
|
super.preSolve(other, contact, oldManifold);
|
|
|
|
|
if (other is! Layered) return;
|
|
|
|
|
// Although, the Layer should already be taking care of the contact
|
|
|
|
|
// filtering, this is to ensure the ball doesn't collide with the ramp base
|
|
|
|
|
// when the filtering is calculated on different time steps.
|
|
|
|
|
contact.setEnabled(other.layer == Layer.board);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@ -441,7 +456,7 @@ class _SpaceshipRampBase extends BodyComponent with Layered, InitialPosition {
|
|
|
|
|
Vector2(4.1, 1.5),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
final bodyDef = BodyDef(position: initialPosition);
|
|
|
|
|
final bodyDef = BodyDef(position: initialPosition, userData: this);
|
|
|
|
|
return world.createBody(bodyDef)..createFixtureFromShape(shape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|