|
|
@ -132,12 +132,8 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
|
|
|
|
final _ballsInside = <Ball>{};
|
|
|
|
final _ballsInside = <Ball>{};
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void begin(
|
|
|
|
void begin(Ball ball, Opening opening, Contact _) {
|
|
|
|
Ball ball,
|
|
|
|
late final Layer layer;
|
|
|
|
Opening opening,
|
|
|
|
|
|
|
|
Contact _,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
Layer layer;
|
|
|
|
|
|
|
|
if (!_ballsInside.contains(ball)) {
|
|
|
|
if (!_ballsInside.contains(ball)) {
|
|
|
|
layer = opening.pathwayLayer;
|
|
|
|
layer = opening.pathwayLayer;
|
|
|
|
_ballsInside.add(ball);
|
|
|
|
_ballsInside.add(ball);
|
|
|
@ -150,24 +146,11 @@ class RampOpeningBallContactCallback<Opening extends RampOpening>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void end(Ball ball, Opening opening, Contact contact) {
|
|
|
|
void end(Ball ball, Opening opening, Contact _) {
|
|
|
|
Layer? layer;
|
|
|
|
final isBallOutsideOpening = opening.orientation == RampOrientation.up
|
|
|
|
|
|
|
|
? ball.body.position.y > opening.body.position.y
|
|
|
|
|
|
|
|
: ball.body.position.y < opening.body.position.y;
|
|
|
|
|
|
|
|
|
|
|
|
switch (opening.orientation) {
|
|
|
|
if (isBallOutsideOpening) ball.layer = Layer.board;
|
|
|
|
case RampOrientation.up:
|
|
|
|
|
|
|
|
if (ball.body.position.y > opening.body.position.y) {
|
|
|
|
|
|
|
|
layer = Layer.board;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RampOrientation.down:
|
|
|
|
|
|
|
|
if (ball.body.position.y < opening.body.position.y) {
|
|
|
|
|
|
|
|
layer = Layer.board;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (layer != null) {
|
|
|
|
|
|
|
|
ball.layer = layer;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|