Camera#
arcade.Camera#
- class arcade.Camera(viewport_width: int = 0, viewport_height: int = 0, window: Optional[Window] = None)[source]#
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.
- Parameters:
- 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.
Example:
# 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: Vec2)[source]#
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: Vec2, speed: float = 1.0)[source]#
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.
- Parameters:
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)[source]#
Resize the camera’s viewport. Call this when the window resizes.
- property rotation: float#
Get or set the rotation in degrees.
This will rotate the camera clockwise meaning the contents will rotate counter-clockwise.
- set_projection()[source]#
Update the projection matrix of the camera. This creates an orthogonal projection based on the viewport size of the camera.