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.
At a glance
9 membersReference
PYTHON APIConstructor
methodCamera(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
propertytransform: TransformThe 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
methodmove_screen(self, delta: Vec2) -> NoneMove the camera by a delta in screen/camera space.
Args
- delta (
Vec2) — Screen-space movement delta.
move_world
methodmove_world(self, delta: Vec2) -> NoneMove the camera by a delta in world space.
Args
- delta (
Vec2) — World movement delta.
rotate
methodrotate(self, delta: float) -> NoneRotate the camera view by a delta in radians.
Args
- delta (
float) — Angle delta in radians.
screen_to_world
methodConvert 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
methodset(self) -> NoneSet this camera as the active one for rendering.
Only one camera can be active at a time.
unset
methodunset(self) -> NoneUnset this camera as the active one for rendering.
world_to_screen
methodConvert 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.