Camera#
The camera controls which part of the scene is visible and how closely it is viewed.
The API exposes the following functions:
| Function | Description |
|---|---|
focusCamera |
Moves the camera center to the given (x,y) position |
zoomCamera |
Sets the camera zoom level |
orientCamera |
Sets the clockwise camera rotation (in radian) |
getCamera |
Returns the camera object |
Usage#
import { focusCamera, zoomCamera, orientCamera, getCamera } from "gamekit-engine/core/camera";
import { degToRad } from "gamekit-engine/utils/math";
focusCamera(10, 20); // Move camera center to (10, 20)
zoomCamera(2); // Set camera zoom to 2x
orientCamera(degToRad(30)) // Rotates the camera clockwise by 30°. This rotates the view counterclockwise by 30°
getCamera(); // { pos: [10, 20], rot: 0.523599, zoom: 2 }
Next Steps#
In the next guide, we'll explore GameKit's rendering system.