MaximumX
Introduction
The MaximumX, MaximumY, MinimumX, and MinimumY properties can set the minimum and maximum X and Y positional values for a given Camera. These properties can be used to create boundaries beyond which the camera cannot move. These are often used in games to keep the camera viewing the playable area and keep areas beyond the playable bounds from being viewed.
Note about Cameras and Entities
If you have a Camera which is part of an Entity then the Camera will be attached to that Entity (by default). The minimum and maximum values will prevent the Camera from moving behond the values you specify, but it will not prevent the parent Entity from moving beyond the bounds. In this situation it is advised to use your own custom min and max implementation.
Code Sample
The following code allows the user to move the camera with the arrow keys on the keyboard, but bounds the position of the Camera to the edges of the AxisAlignedRectangle created in the Initialize method.
Add the following to your Screen's CustomInitialize:
Add the following to Update
Removing Minimum and Maximum Values
Last updated