CLASS v1.8.0

Camera

pykraken.Camera

Represents a 2D camera used for rendering.

More about Camera

The camera position is the world point displayed at the center of the current render target.

Reference

PYTHON API
Camera(set_active: bool = False)

Create a camera with an optional active state.

Args

  • set_active (bool, optional) — Whether to set this camera as active, unsetting any existing active camera. Defaults to false.

transform

property
transform: Transform

The camera transform. transform.pos is the world point at the center of the view. transform.angle rotates the rendered view in radians. transform.scale is reserved for future zoom support.

move_screen(self, delta: Vec2) -> None

Move the camera by a delta in screen/camera space.

Args

  • delta (Vec2) — Screen-space movement delta.
move_world(self, delta: Vec2) -> None

Move the camera by a delta in world space.

Args

  • delta (Vec2) — World movement delta.

rotate

method
rotate(self, delta: float) -> None

Rotate the camera view by a delta in radians.

Args

  • delta (float) — Angle delta in radians.
screen_to_world(self, screen_pos: Vec2) -> Vec2

Convert a screen position to a world position using this camera.

Args

  • screen_pos (Vec2) — The screen position to convert.

Returns

  • Vec2 — The resulting world position.

set

method
set(self) -> None

Set this camera as the active one for rendering.

Only one camera can be active at a time.

unset

method
unset(self) -> None

Unset this camera as the active one for rendering.

world_to_screen(self, world_pos: Vec2) -> Vec2

Convert a world position to a screen position using this camera.

Args

  • world_pos (Vec2) — The world position to convert.

Returns

  • Vec2 — The resulting screen position.

Find your next step

Start typing to search the manual.