Camera
This page is up to date for MonoGame.Extended 4.0.3
. If you find outdated information, please open an issue.
The purpose of a camera is to provide a quick way show the game world from a different position in space. The way the camera does this is by using a transformation matrix that changes the way a sprite batch is rendered to the screen. This allows no movement of objects, and instead, moves the projected image on screen space.
Currently there is only one camera type, the Orthographic Camera
.
This Class is an abstract class only, use a concrete class like the Orthographic Camera
, or create your own sub-class.
Why would you want to use a camera?
The short answer is, to reduce complexity for moving what is displayed on the screen.
Most games allow you to move around in the game world. For this there are 2 main ways you could accomplish this.
- Loop over all objects (enemies, players, tiles, backgrounds) in your game, and move their positions, rotations, and scale them. Every frame...
- or... leave them where they are at, but use math (Matrix multiplication) to "project" the sprites to a new location (Camera).
The 2nd option is where the camera object comes in. The camera can follow the player (or another entity), displaying the world around the entity. The world is not moved though, only the entity and the camera move.
What can you do with the camera?
A camera has manage advantages, here are a few:
- Move the viewable area with an object (Like the player)
- Add a zoom effect (Perhaps entering or leaving a building)
- Add a rotation effect (Perhaps when entering a battle)
- Change to letterbox (Cinematic) view
- Create fluid motions with ease following a path