Camera Settings

Introduction

The Camera Settings in Glue allows you to set your Camera and resolution project-wide. To access the settings click Settings-> Camera Settings or click the camera icon.

SettingsCameraSettings.png

This will bring up the camera window.

 

Camera and Resolution Variables

Is 2D

The “Is2D” property will control whether the camera is in 2D mode or 3D mode. In 2D mode, your screen will use pixel coordinates. In other words, if your screen resolution is 800 wide, then an object with 800 width will take up the entire screen.

If Is2D is false, then the Camera will be in 3D mode, and the size of objects depends on the Z of the camera.

Resolution Width

Controls the width of the game window. Increasing this value will make the game window wider and (by default) will display more of the game world.

Resolution Height

Controls the height of the game window. Increasing this value will make the game window taller and (by default) will display more of the game world.

Fixed Aspect Ratio

If checked, the game will maintain a fixed aspect ratio as specified by the horizontal and vertical ratio values.

If the game window is does not match the desired aspect ratio, the game will be letterboxed or pillarboxed.

For example, consider these variables:

  • Width = 400
  • Height = 400
  • Fixed Aspect Ratio = true
  • Aspect Ratio = 16 : 9

Fullscreen

Whether the game runs in full screen. If unchecked the game runs in windowed mode. Note that fullscreen is “borderless fullscreen” which means it does not change the display adaptor’s actual resolution. This means that alt-tabbing will be much faster and textures will not get unloaded when the game loses focus.

Allow Window Resizing

Whether the window can be resized by dragging the edges. If false, the window cannot be resized by the user by grabbing the edges.

Scale

A percentage value used to make the window larger or smaller. A larger value will make the window larger, stretching the contents of the game window. For example, a 200×200 game window at 300 scale will draw at 600×600, with each object in the game being three times as wide and three times as tall.

On Resize

Controls the behavior of the contents of the game window when the game window is resized.

If set to Preserve (Stretch) Visible Area, stretching the game window will not allow the user to see more of the game world – instead objects will become larger as the window is stretched.

If set to Increase Visible Area, stretching the game window will allow the user to see more of the game world – objects will remain the same size.

Changing Resolution and Camera Values in Initialize Code

Glue’s camera window provides an easy way to set the default behavior of your game, and it can be used to change camera settings during development. Many games allow the user to customize the window (such as by setting if the game runs in full screen), and the resolution information is then saved in a configuration file.

The generated code for camera settings allows changing the Glue-assigned values prior to the window being created.

To modify the settings in initialize:

  1. Open your project in Visual Studio
  2. Open Game1.cs
  3. Find the following line of code in the Game1’s Initialize  method:
    CameraSetup.SetupCamera(SpriteManager.Camera, graphics);
  4. Add code to assign values to  CameraSetup.Data  before the call to SetupCamera

For example, the following code could be used to set the values, assuming configurationData  is a valid object:

Changing Resolution and Camera Values After Initialize

Camera and resolution values can be changed after initialize. Some games provide control over the resolution in a settings window. The generated CameraSetup object can be modified at any point in the game’s execution.

For example, the following code could be used to adjust the resolution and camera settings when the user presses the space bar:

Notice that the above code calls both ResetWindow  and ResetCamera . Typically modifications to the CameraSetup.Data require both to be called. The two functions are separated because Glue generated code calls ResetCamera inbetween each screen.