|
|
@ -17,20 +17,21 @@ class LaunchRamp extends Forge2DBlueprint {
|
|
|
|
RampOpeningBallContactCallback<_LaunchRampExit>(),
|
|
|
|
RampOpeningBallContactCallback<_LaunchRampExit>(),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
final launchRampBase = _LaunchRampBase()..layer = Layer.launcher;
|
|
|
|
final launchRampBase = _LaunchRampBase();
|
|
|
|
|
|
|
|
|
|
|
|
final launchRampForegroundRailing = _LaunchRampForegroundRailing()
|
|
|
|
final launchRampForegroundRailing = _LaunchRampForegroundRailing();
|
|
|
|
..layer = Layer.launcher;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final launchRampExit = _LaunchRampExit(rotation: math.pi / 2)
|
|
|
|
final launchRampExit = _LaunchRampExit(rotation: math.pi / 2)
|
|
|
|
..initialPosition = Vector2(1.8, 34.2)
|
|
|
|
..initialPosition = Vector2(0.6, 34);
|
|
|
|
..layer = Layer.opening
|
|
|
|
|
|
|
|
..renderBody = false;
|
|
|
|
final launchRampCloseWall = _LaunchRampCloseWall()
|
|
|
|
|
|
|
|
..initialPosition = Vector2(4, 66.5);
|
|
|
|
|
|
|
|
|
|
|
|
addAll([
|
|
|
|
addAll([
|
|
|
|
launchRampBase,
|
|
|
|
launchRampBase,
|
|
|
|
launchRampForegroundRailing,
|
|
|
|
launchRampForegroundRailing,
|
|
|
|
launchRampExit,
|
|
|
|
launchRampExit,
|
|
|
|
|
|
|
|
launchRampCloseWall,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,10 +41,7 @@ class LaunchRamp extends Forge2DBlueprint {
|
|
|
|
/// {@endtemplate}
|
|
|
|
/// {@endtemplate}
|
|
|
|
class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
|
|
|
|
class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
|
|
|
|
/// {@macro launch_ramp_base}
|
|
|
|
/// {@macro launch_ramp_base}
|
|
|
|
_LaunchRampBase()
|
|
|
|
_LaunchRampBase() : super(priority: Ball.launchRampPriority - 1) {
|
|
|
|
: super(
|
|
|
|
|
|
|
|
priority: Ball.launchRampPriority - 1,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
layer = Layer.launcher;
|
|
|
|
layer = Layer.launcher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -143,15 +141,9 @@ class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
|
|
|
|
/// Foreground railing for the [_LaunchRampBase] to render in front of the
|
|
|
|
/// Foreground railing for the [_LaunchRampBase] to render in front of the
|
|
|
|
/// [Ball].
|
|
|
|
/// [Ball].
|
|
|
|
/// {@endtemplate}
|
|
|
|
/// {@endtemplate}
|
|
|
|
class _LaunchRampForegroundRailing extends BodyComponent
|
|
|
|
class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
|
|
|
|
with InitialPosition, Layered {
|
|
|
|
|
|
|
|
/// {@macro launch_ramp_foreground_railing}
|
|
|
|
/// {@macro launch_ramp_foreground_railing}
|
|
|
|
_LaunchRampForegroundRailing()
|
|
|
|
_LaunchRampForegroundRailing() : super(priority: Ball.launchRampPriority + 1);
|
|
|
|
: super(
|
|
|
|
|
|
|
|
priority: Ball.launchRampPriority + 1,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
layer = Layer.launcher;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
List<FixtureDef> _createFixtureDefs() {
|
|
|
|
final fixturesDef = <FixtureDef>[];
|
|
|
|
final fixturesDef = <FixtureDef>[];
|
|
|
@ -221,6 +213,26 @@ class _LaunchRampForegroundRailingSpriteComponent extends SpriteComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _LaunchRampCloseWall extends BodyComponent with InitialPosition, Layered {
|
|
|
|
|
|
|
|
_LaunchRampCloseWall() {
|
|
|
|
|
|
|
|
layer = Layer.board;
|
|
|
|
|
|
|
|
renderBody = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Body createBody() {
|
|
|
|
|
|
|
|
final shape = EdgeShape()..set(Vector2.zero(), Vector2(0, 4));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final fixtureDef = FixtureDef(shape);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final bodyDef = BodyDef()
|
|
|
|
|
|
|
|
..userData = this
|
|
|
|
|
|
|
|
..position = initialPosition;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return world.createBody(bodyDef)..createFixture(fixtureDef);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// {@template launch_ramp_exit}
|
|
|
|
/// {@template launch_ramp_exit}
|
|
|
|
/// [RampOpening] with [Layer.launcher] to filter [Ball]s exiting the
|
|
|
|
/// [RampOpening] with [Layer.launcher] to filter [Ball]s exiting the
|
|
|
|
/// [LaunchRamp].
|
|
|
|
/// [LaunchRamp].
|
|
|
@ -232,9 +244,14 @@ class _LaunchRampExit extends RampOpening {
|
|
|
|
}) : _rotation = rotation,
|
|
|
|
}) : _rotation = rotation,
|
|
|
|
super(
|
|
|
|
super(
|
|
|
|
insideLayer: Layer.launcher,
|
|
|
|
insideLayer: Layer.launcher,
|
|
|
|
|
|
|
|
outsideLayer: Layer.board,
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
orientation: RampOrientation.down,
|
|
|
|
insidePriority: Ball.launchRampPriority,
|
|
|
|
insidePriority: Ball.launchRampPriority,
|
|
|
|
);
|
|
|
|
outsidePriority: 0,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
layer = Layer.launcher;
|
|
|
|
|
|
|
|
renderBody = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final double _rotation;
|
|
|
|
final double _rotation;
|
|
|
|
|
|
|
|
|
|
|
|