- class arcade.Camera(viewport_width: int = 0, viewport_height: int = 0, window: Optional[arcade.application.Window] = None)#
The Camera class is used for controlling the visible viewport. It is very useful for separating a scrolling screen of sprites, and a GUI overlay. For an example of this in action, see Move with a Scrolling Screen - Centered.
- property anchor: Optional[Tuple[float, float]]#
Get or set the rotation anchor for the camera.
By default, the anchor is the center of the screen and the anchor value is None. Assigning a custom anchor point will override this behavior. The anchor point is in world / global coordinates.
# Set the anchor to the center of the world camera.anchor = 0, 0 # Set the anchor to the center of the player camera.anchor = player.position
- move(vector: pyglet.math.Vec2)#
Moves the camera with a speed of 1.0, aka instant move
This is equivalent to calling move_to(my_pos, 1.0)
- move_to(vector: pyglet.math.Vec2, speed: float = 1.0)#
Sets the goal position of the camera.
The camera will lerp towards this position based on the provided speed, updating its position every time the use() function is called.
vector (Vec2) – Vector to move the camera towards.
speed (Vec2) – How fast to move the camera, 1.0 is instant, 0.1 moves slowly
- resize(viewport_width: int, viewport_height: int)#
Resize the camera’s viewport. Call this when the window resizes.
- property rotation: float#
Get or set the rotation in angles.
This will rotate the camera clockwise meaning the contents will rotate counter-clockwise.
Update the projection matrix of the camera. This creates an orthogonal projection based on the viewport size of the camera.
- shake(velocity: pyglet.math.Vec2, speed: float = 1.5, damping: float = 0.9)#
Add a camera shake.
Update the camera’s viewport to the current settings.
Select this camera for use. Do this right before you draw.