Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about to use viewfinder.zoom in forge2d instead of use OpenGL zoom. #2606

Closed
mrbeardad opened this issue Jul 16, 2023 · 1 comment · Fixed by #2728
Closed

How about to use viewfinder.zoom in forge2d instead of use OpenGL zoom. #2606

mrbeardad opened this issue Jul 16, 2023 · 1 comment · Fixed by #2728

Comments

@mrbeardad
Copy link

Problem to solve

The default zoom of Forge2DGame is 10, which use OpenGL to zoom the entire game, include world and camera component. So the components in viewport is also scaled. And the viewport is actually bigger than window!
image

Proposal

Use viewfinder to zoom the world, so the camera component works properly.

class Forge2DExample extends Forge2DGame {
  late final CameraComponent mainCamera;
  late final World cameraWorld;

  Forge2DExample() : super(zoom: 1);

  @override
  Future<void> onLoad() async {
    cameraWorld = World();
    mainCamera = CameraComponent(world: cameraWorld)
      ..viewport.add(AlignComponent(child: FpsTextComponent()))
      ..viewfinder.anchor = Anchor.topLeft
      ..viewfinder.zoom = zoom; // and use vector.scaled(1/zoom) to transform pixles to forge world meters
    addAll([mainCamera, cameraWorld]);
    // ...
  }
}

More information

@spydon
Copy link
Member

spydon commented Jul 16, 2023

This is already underway, since flame_forge2d unfortunately almost is unusable now with the new CameraComponent system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants