You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
Proposal
Use viewfinder to zoom the world, so the camera component works properly.
classForge2DExampleextendsForge2DGame {
latefinalCameraComponent mainCamera;
latefinalWorld cameraWorld;
Forge2DExample() :super(zoom:1);
@overrideFuture<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 metersaddAll([mainCamera, cameraWorld]);
// ...
}
}
More information
The text was updated successfully, but these errors were encountered:
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!
Proposal
Use viewfinder to zoom the world, so the camera component works properly.
More information
The text was updated successfully, but these errors were encountered: