The OrthogonalHeight and OrthogonalWidth values control how many units tall and wide the view of the Camera can be seen. These values apply if the camera is 2D (if the Orthogonal value is set to true). If using Glue, the default setup is for a 2D camera. Orthogonal cameras are useful for creating 2D games, or for creating menu systems which work in pixels.
By default FlatRedBall games use a 2D camera with an OrthogonalWidth of 800 and OrthogonalHeight of 600. The following diagram can help visualize this configuration:
By default, FlatRedBall games have their resolution controlled by the Display Settings in the FlatRedBall Editor.
These values can be changed by typing new values in the Width and Height boxes or by using the dropdown to change both values.
The OrthogonalHeight and OrthogonalWidth values can be used to position an object at the edge of the screen. Keep in mind that a Camera's X and Y values represent the center of the screen, so the edges of the screen can be obtained by adding or subtracting half of the OrthogonalWidth or OrthogonalHeight.
The Camera's UsePixelCoordinates method sets the calling Camera's Orthogonal property to true and adjusts the pixel coordinates to the screen's resolution. In other words, if the screen is 800X600, calling UsePixelCoordinates sets the OrthogonalWidth to 800 and the OrthogonalHeight to 600.
OrthogonalWidth and OrthogonalHeight control how much of the world can be seen. For example, consider the following game level which is 3200x3200 pixels (zoomed down to fit on screen):
If this level were viewed with a camera with OrthogonalWidth of 800 and an OrthogonalHeight of 480, the red square represents the area that might be visible at one time:
The following image shows what this might look like in a FlatRedBall game:
When using a 3D camera (Orthogonal = false) the most common way to perform a "zoom in" is to adjust the Camera's Z value. When objects move closer to the Camera in a perspective view, they become larger. This is not the case when the Camera is Orthogonal. The following code adjusts the Camera's OrthogonalHeight and OrthogonalWidth (through the FixAspectRatioYConstant method) by using the up/down keys on the keyboard. Add the following to Initialize after initializing FlatRedBall:
Add the following to your Screen's CustomActivity:
Note that the code above adjusts OrthogonalHeight, then fixes the aspect ratio keeping the Y (height) constant. This code could also be written to adjust OrthogonalWidth and call FixAspectRatioXConstant
; however it's common to have OrthogonalHeight be the dominant axis since aspect ratio can vary widely on monitors.