Skip to content

Commit

Permalink
docs: Remove PositionType from the docs (#3198)
Browse files Browse the repository at this point in the history
`PositionType` was deprecated a long time ago, this PR just remove the
non-exported enum and its docs.
  • Loading branch information
spydon authored Jun 18, 2024
1 parent e870493 commit b0ff5c4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 47 deletions.
31 changes: 0 additions & 31 deletions doc/flame/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion packages/flame/lib/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
15 changes: 0 additions & 15 deletions packages/flame/lib/src/components/core/position_type.dart

This file was deleted.

0 comments on commit b0ff5c4

Please sign in to comment.