skip to Main Content

I am a beginner in development, and I have started to develop a small game with Flutter and Flame. However, I have a problem: how can I define a maximum size for my game for users who might be on a browser on a PC (since my game is a platformer)?

I have tried everything, but unfortunately, I can’t get it to work; the game takes up the entire screen.

Thank you very much

2

Answers


  1. How do you define "maximum game size"?
    How about the aspect ratio? Can it be played in portrait mode, or just on horizontal screens?

    there are a lot of constraints we can work on just to decide how we show our game area.
    In the old days, the game would have fixed size and aspect ratio, usually 4:3 size, and it would scale, depending on the width or the height of the screen, in a way it wouldn’t deform the game.

    Nowadays there are better ways to do that.
    Since you want to create a platformer, there’s not a big difference in the gameplay depending on the size of the screen, except if you create a game for very big screens, which would put a big tool on players with lower resolution screens, that probably won’t be able to see the full scene.

    Just be aware that if your game has too much resolution, and too much happening at the same time, bigger screens will suffer performance issues, because Flutter is not exactly an efficient Game dev platform.

    My advice is to make the game area in the lowest resolution possible, but in a way it can still have good art, and scale it to bigger screens, keeping the resolution.

    Login or Signup to reply.
  2. From reading your comment to the other answer I think I know what you are looking for, and that is the FixedSizeViewport if you are using the CameraComponent (which I suggest that you do), if you are using the legacy camera it is called FixedResolutionViewport.

    When creating the CameraComponent you can use the specific constructor for this to have it set up this viewport for you (or you can set the viewport manually afterwards):

    final cameraComponent = CameraComponent.withFixedResolution(width: 800, height: 600);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search