@ujjwalvivek/tinyts
    Preparing search index...

    Class Camera

    2D camera with follow, deadzone, shake, and world-bounds clamping.

    Index

    Constructors

    Properties

    bounds: { pos: Vec2; size: Vec2 } | null

    World-space boundary constraint.

    pos: Vec2

    Camera center position.

    rotation: number

    Camera rotation in radians.

    size: Vec2

    Viewport size in pixels.

    zoom: number

    Camera zoom level.

    Methods

    • Push the camera transform onto the renderer. Call before drawing world objects.

      Returns void

    • Pop the camera transform. Call after drawing world objects.

      Returns void

    • Follow a target position each frame.

      Parameters

      • target: Vec2 | { x: number; y: number }

        Object with x,y to track.

      • Optionaloptions: { deadZone?: Vec2; lookahead?: Vec2; speed?: number }

        Follow options (deadzone, lookahead, speed).

      Returns void

    • Trigger a screen shake with the given pixel intensity (lasts 0.25s).

      Parameters

      • intensity: number

      Returns void

    • Stop following the current target.

      Returns void

    • Advance follow, shake, and bounds clamping by dt seconds.

      Parameters

      • dt: number

      Returns void