From 806020389dc1ad0313dceb6544357e183384e85b Mon Sep 17 00:00:00 2001 From: Allison Ryan Date: Fri, 8 Apr 2022 14:37:02 -0500 Subject: [PATCH] fix: launch ramp render issue --- lib/game/components/controlled_ball.dart | 1 + lib/game/pinball_game.dart | 2 +- .../lib/src/components/boundaries.dart | 6 +++--- .../lib/src/components/dino_walls.dart | 2 +- .../lib/src/components/launch_ramp.dart | 11 ++++++++--- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/game/components/controlled_ball.dart b/lib/game/components/controlled_ball.dart index cef076d8..81746f0f 100644 --- a/lib/game/components/controlled_ball.dart +++ b/lib/game/components/controlled_ball.dart @@ -18,6 +18,7 @@ class ControlledBall extends Ball with Controls { required PinballTheme theme, }) : super(baseColor: theme.characterTheme.ballColor) { controller = BallController(this); + priority = LaunchRamp.ballPriorityInsideRamp; } /// {@template bonus_ball} diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index 4ccad9db..52ef5064 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -168,7 +168,7 @@ class DebugPinballGame extends PinballGame with TapDetector { anchor: Anchor.center, ) ..position = Vector2(0, -7.8) - ..priority = -2; + ..priority = -4; await add(spriteComponent); } diff --git a/packages/pinball_components/lib/src/components/boundaries.dart b/packages/pinball_components/lib/src/components/boundaries.dart index 16c0f7b7..d0a64fa3 100644 --- a/packages/pinball_components/lib/src/components/boundaries.dart +++ b/packages/pinball_components/lib/src/components/boundaries.dart @@ -13,7 +13,7 @@ class Boundaries extends Forge2DBlueprint { final bottomBoundary = _BottomBoundary(); final outerBoundary = _OuterBoundary(); - addAll([bottomBoundary, outerBoundary]); + addAll([outerBoundary, bottomBoundary]); } } @@ -23,7 +23,7 @@ class Boundaries extends Forge2DBlueprint { /// {@endtemplate bottom_boundary} class _BottomBoundary extends BodyComponent with InitialPosition { /// {@macro bottom_boundary} - _BottomBoundary() : super(priority: 2); + _BottomBoundary() : super(priority: 1); List _createFixtureDefs() { final fixturesDefs = []; @@ -88,7 +88,7 @@ class _BottomBoundarySpriteComponent extends SpriteComponent with HasGameRef { /// {@endtemplate outer_boundary} class _OuterBoundary extends BodyComponent with InitialPosition { /// {@macro outer_boundary} - _OuterBoundary() : super(priority: -1); + _OuterBoundary() : super(priority: LaunchRamp.ballPriorityInsideRamp - 1); List _createFixtureDefs() { final fixturesDefs = []; diff --git a/packages/pinball_components/lib/src/components/dino_walls.dart b/packages/pinball_components/lib/src/components/dino_walls.dart index dc5b7a26..aec4c7aa 100644 --- a/packages/pinball_components/lib/src/components/dino_walls.dart +++ b/packages/pinball_components/lib/src/components/dino_walls.dart @@ -124,7 +124,7 @@ class _DinoTopWallSpriteComponent extends SpriteComponent with HasGameRef { /// {@endtemplate} class _DinoBottomWall extends BodyComponent with InitialPosition { ///{@macro dino_top_wall} - _DinoBottomWall() : super(priority: 1); + _DinoBottomWall(); List _createFixtureDefs() { final fixturesDef = []; diff --git a/packages/pinball_components/lib/src/components/launch_ramp.dart b/packages/pinball_components/lib/src/components/launch_ramp.dart index 2eea7a91..407319d2 100644 --- a/packages/pinball_components/lib/src/components/launch_ramp.dart +++ b/packages/pinball_components/lib/src/components/launch_ramp.dart @@ -11,6 +11,9 @@ import 'package:pinball_components/pinball_components.dart'; /// [_LaunchRampForegroundRailing]. /// {@endtemplate} class LaunchRamp extends Forge2DBlueprint { + /// Base priority for [Ball] while inside [LaunchRamp]. + static const ballPriorityInsideRamp = -2; + @override void build(_) { addAllContactCallback([ @@ -40,7 +43,7 @@ class LaunchRamp extends Forge2DBlueprint { /// {@endtemplate} class _LaunchRampBase extends BodyComponent with InitialPosition, Layered { /// {@macro launch_ramp_base} - _LaunchRampBase() : super(priority: -1) { + _LaunchRampBase() : super(priority: LaunchRamp.ballPriorityInsideRamp - 1) { layer = Layer.launcher; } @@ -143,7 +146,8 @@ class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef { class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition, Layered { /// {@macro launch_ramp_foreground_railing} - _LaunchRampForegroundRailing() : super(priority: 1) { + _LaunchRampForegroundRailing() + : super(priority: LaunchRamp.ballPriorityInsideRamp + 1) { layer = Layer.launcher; } @@ -227,7 +231,8 @@ class _LaunchRampExit extends RampOpening { super( insideLayer: Layer.launcher, orientation: RampOrientation.down, - insidePriority: 3, + insidePriority: LaunchRamp.ballPriorityInsideRamp, + outsidePriority: 0, ); final double _rotation;