From a6d716b016322330c8e55795fe462cad4995aa2d Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Tue, 18 Jun 2024 10:50:07 +0200 Subject: [PATCH 1/2] docs: Remove PositionType from the docs --- doc/flame/components.md | 31 ------------------- .../src/components/core/position_type.dart | 15 --------- 2 files changed, 46 deletions(-) delete mode 100644 packages/flame/lib/src/components/core/position_type.dart diff --git a/doc/flame/components.md b/doc/flame/components.md index 643bfe0f9f8..6de96f6dd01 100644 --- a/doc/flame/components.md +++ b/doc/flame/components.md @@ -360,37 +360,6 @@ void onDragUpdate(DragUpdateInfo info) { ``` -### PositionType - -```{note} -If you are using the `CameraComponent` you should not use `PositionType`, but -instead adding your components directly to the viewport for example if you -want to use them as a HUD. -``` - -If you want to create a HUD (Head-up display) or another component that isn't positioned in relation -to the game coordinates, you can change the `PositionType` of the component. -The default `PositionType` is `positionType = PositionType.game` and that can be changed to -either `PositionType.viewport` or `PositionType.widget` depending on how you want to position -the component. - -- `PositionType.game` (Default) - Respects camera and viewport. -- `PositionType.viewport` - Respects viewport only (ignores camera). -- `PositionType.widget` - Position in relation to the coordinate system of the Flutter game - widget (i.e. the raw canvas). - -Most of your components will probably be positioned according to `PositionType.game`, since you -want them to respect the `Camera` and the `Viewport`. But quite often you want for example buttons -and text to always show on the screen, no matter if you move the camera, then you want to use -`PositionType.viewport`. In some rare cases you want to use `PositionType.widget` to position -your widgets, when you don't want the component to respect the camera nor the viewport; this could -for example be for controls or joysticks that would not be ergonomic to use if they had to stay -within the viewport. - -Do note that this setting is only respected if the component is added directly to the root -`FlameGame` and not as a child component of another component. - - ### Visibility of components The recommended way to hide or show a component is usually to add or remove it from the tree diff --git a/packages/flame/lib/src/components/core/position_type.dart b/packages/flame/lib/src/components/core/position_type.dart deleted file mode 100644 index f851b5e7371..00000000000 --- a/packages/flame/lib/src/components/core/position_type.dart +++ /dev/null @@ -1,15 +0,0 @@ -/// Used to define which coordinate system a given top-level component respects. -/// -/// Normally components live in the "game" coordinate system, which just means -/// they respect both the camera and viewport. -enum PositionType { - /// Default type. Respects camera and viewport (applied on top of widget). - game, - - /// Respects viewport only (ignores camera) (applied on top of widget). - viewport, - - /// Position in relation to the coordinate system of the Flutter game widget - /// (i.e. the raw canvas). - widget, -} From 8ea3375567f0af5c4de9702f33ebf867e459006a Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Tue, 18 Jun 2024 11:16:02 +0200 Subject: [PATCH 2/2] Remove export of PositionType --- packages/flame/lib/components.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/flame/lib/components.dart b/packages/flame/lib/components.dart index fc38c161285..08bbde1ff2e 100644 --- a/packages/flame/lib/components.dart +++ b/packages/flame/lib/components.dart @@ -11,7 +11,6 @@ export 'src/components/components_notifier.dart'; export 'src/components/core/component.dart'; export 'src/components/core/component_key.dart'; export 'src/components/core/component_set.dart'; -export 'src/components/core/position_type.dart'; export 'src/components/custom_painter_component.dart'; export 'src/components/fps_component.dart'; export 'src/components/fps_text_component.dart';