diff --git a/packages/trashy_road/lib/src/game/game.dart b/packages/trashy_road/lib/src/game/game.dart index 39bb3b67..373b7bff 100644 --- a/packages/trashy_road/lib/src/game/game.dart +++ b/packages/trashy_road/lib/src/game/game.dart @@ -157,19 +157,12 @@ class TrashyRoadGame extends FlameGame } } -class _CameraMan extends PositionComponent { +class _CameraMan extends PositionComponent + with HasGameReference { _CameraMan({required this.actor}); final PositionComponent actor; - static final _offset = UnmodifiableVector2View(0, -200); - - void _updatePosition() { - position - ..setFrom(actor.position) - ..add(_offset); - } - @override FutureOr onLoad() async { await super.onLoad(); @@ -181,4 +174,10 @@ class _CameraMan extends PositionComponent { super.update(dt); _updatePosition(); } + + void _updatePosition() { + position + ..setFrom(actor.position) + ..y -= game.camera.viewport.size.y / 4.25; + } }