Example – Adding a Camera to GameScreen
Cameras added to a Screen can be modified in the FlatRedBall Editor. By default, adding a Camera object to a Screen does not create a new Camera, but rather it provides access to the main Camera. For more information, see the IsNewCamera property below.
To access the camera in a Screen:
- Select the Screen to contain the object. To make changes for all levels, select the GameScreen.
- Click the Add Object button to add a new object to the screen
- Select Camera as the type and click OK
The new camera appears in the GameScreen.
It can be modified to make changes to the game, including in edit mode. For example, the Background Color can be changed from Black to any desired color.
The IsNewCamera property is a property which only appears on objects which are of type Camera.
- If this property is false (the default value) then the Camera object is assigned to the main Camera (FlatRedBall.Camera.Main).
- If this property is true, Glue will create a new Camera instance. This is not often used but can be used for split-screen games.
If you are developing a game which requires logic for initializing or controlling the Camera then you may want to organize this code into an Entity. The Camera object facilitates setting this up in Glue. The process is as follows:
- Create an Entity which will contain all of the logic. For example an Entity named CameraEntity
- Right-click on the CameraEntity’s objects and add a new object
- Select Camera as the type
Now you can code logic in the CustomInitialize and CustomActivity of your CameraEntity.