Last updated
Was this helpful?
Last updated
Was this helpful?
The Camera is a therefore it has a Position variable which works the same as the . The default position for Cameras is:
Projects which have been created with the Wizard will have a CameraControllingEntity instance in the GameScreen. This instance automatically adjusts the position of the camera according to its own settings.
The default (unrotated Camera) looks down the Z axis. This means that if you want the center of the screen to be at a certain coordinate, you simply need to set the Camera's X and Y value.
By default a TileMap's top-left corner will be positioned at X=0, Y=0. By default, the camera is centered at X=0, Y=0, so the top left of the map will appear in the center of the screen. For example, the following image shows how a level will appear in Tiled and in game:
One way to solve this problem is to change the Camera's X and Y values to be at the center of the tilemap. This can be adjusted by using the dimensions of the map, or arbitrarily by adding some constant value to the X and subtracting some value from the Y. For example, the following code will center on the map:
Now the Camera will be centered on the map as shown in the following image:
If your game includes a CameraControllingEntityInstance, then the Camera's position will automatically be determined by this object. If you would like to manually control the Camera, you can delete the CameraControllingEntityInstance from your game. For more information on how to use the CameraControllingEntity, see the .
Changing the Z value of the Camera will make the camera move "forward" and "backward" in the world. This is a way to simulate zooming (technically "zooming" is accomplished by changing the Camera's ). This will only work on 3D cameras. To make objects appear smaller, you will want to increase the Z value of the Camera. For example: