- class arcade.Camera(*, viewport: Tuple[int, int, int, int] | None = None, projection: Tuple[float, float, float, float] | None = None, zoom: float = 1.0, rotation: float = 0.0, anchor: Tuple[float, float] | None = None, window: Window | None = None)#
The Camera class is used for controlling the visible viewport, the projection, zoom and rotation. 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.
viewport – (left, bottom, width, height) size of the viewport. If None the window size will be used.
projection – (left, right, bottom, top) size of the projection. If None the window size will be used.
zoom – the zoom to apply to the projection
rotation – the angle in degrees to rotate the projection
anchor – the x, y point where the camera rotation will anchor. Default is the center of the viewport.
window – Window to associate with this camera, if working with a multi-window program.
- get_sprites_at_point(point: Point, sprite_list: SpriteList) List['Sprite'] #
Get a list of sprites at a particular point when This function sees if any sprite overlaps the specified point. If a sprite has a different center_x/center_y but touches the point, this will return that sprite.
point – Point to check
sprite_list – SpriteList to check against
List of sprites colliding, or an empty list.
- shake(velocity: Vec2 | tuple, speed: float = 1.5, damping: float = 0.9) None #
Add a camera shake.
velocity – Vector to start moving the camera
speed – How fast to shake
damping – How fast to stop shaking
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
The far applied to the projection
The near applied to the projection
Get or set the rotation in degrees.
This will rotate the camera clockwise meaning the contents will rotate counter-clockwise.
Returns the x, y scale.
The zoom applied to the projection. Just returns the x scale value.
- class arcade.SimpleCamera(*, viewport: Tuple[int, int, int, int] | None = None, projection: Tuple[float, float, float, float] | None = None, window: Window | None = None)#
A simple camera that allows to change the viewport, the projection and can move around. That’s it. See arcade.Camera for more advance stuff.
viewport – Size of the viewport: (left, bottom, width, height)
projection – Space to allocate in the viewport of the camera (left, right, bottom, top)
- get_map_coordinates(camera_vector: Vec2 | tuple) Vec2 #
Returns map coordinates in pixels from screen coordinates based on the camera position
camera_vector – Vector captured from the camera viewport
- move(vector: Vec2 | tuple) None #
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 | tuple, speed: float = 1.0) None #
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 – Vector to move the camera towards.
speed – How fast to move the camera, 1.0 is instant, 0.1 moves slowly
- resize(viewport_width: int, viewport_height: int, *, resize_projection: bool = True) None #
Resize the camera’s viewport. Call this when the window resizes.
viewport_width – Width of the viewport
viewport_height – Height of the viewport
resize_projection – if True the projection will also be resized
Update the camera’s viewport to the current settings.
The dimensions of the space to project in the camera viewport (left, right, bottom, top). The projection is what you want to project into the camera viewport.
The ratio of projection height to viewport height
The ratio of projection width to viewport width
The space the camera will hold on the screen (left, bottom, width, height)
Returns the height of the viewport
The ratio of viewport height to projection height
The ratio of viewport width to projection width
Returns the width of the viewport