TopDestination
Introduction
The TopDestination, BottomDestination, LeftDestination, and RightDestination properties of the LayerCameraSettings class allow Layers to render to only a portion of the Screen (also known as creating a mask). These coordinates are measured in pixel units in screen space. In other words, 0 is the left side of the screen for LeftDestination and RightDestination, and it increases to the right. The value of 0 is the top of the screen for TopDestination and BottomDestination, and it increases downward. The destination values are not necessarily used when a given Layer is rendered. The default value for TopDestination, BottomDestination, LeftDestination, and RightDestination is -1. If -1 is used, then the Camera's DestinationRectangle values are used.
Code Example
The following code creates a LayerCameraSetting which has a 200 pixel border around the edges of the screen. The Layer draws a large Sprite which is masked by the destination values of the LayerCameraSettings. Add the following using statement:
Add the following to Initialize after initializing FlatRedBall:
Exceptions related to display size
If you are explicitly setting the destination rectangle of a LayerCameraSettings object, then you may encounter an exception. If FlatRedBall detects that the BottomDestination is too large, you may get an error as follows:
Similarly you may get a message about the width, which might read:
You can fix this in one of the following ways:
Prevent resizing of your game window
Adjust the LayerCameraSettings for your Layer to fit within the bounds of the display
Set the LayerCameraSettings' destination values to -1, which will result it in automatically adjusting to its contained Camera destination.
Last updated