Skip to main content

Camera

Up to date

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.

Side View
Camera
Screen / Scene
Camera
Front View
Screen / Scene
Viewable Area
Composite View
Camera

A quick sketch of a virtual camera looking at a scene of a 2D world, from 3 different perspectives; Licensed for free and commercial use.

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.

  1. Loop over all objects (enemies, players, tiles, backgrounds) in your game, and move their positions, rotations, and scale them. Every frame...
  2. 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.

Overview of conceptual layers of the camera; Licensed for free and commercial use.

What can you do with the camera?

A camera has manage advantages, here are a few:

  1. Move the viewable area with an object (Like the player)
  2. Add a zoom effect (Perhaps entering or leaving a building)
  3. Add a rotation effect (Perhaps when entering a battle)
  4. Change to letterbox (Cinematic) view
  5. Create fluid motions with ease following a path

Further Reading