# nodesnim/nodes2d/camera2d

Dark Mode

Search:
Group by:

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../nodes/node, node2d

# Types

    Camera2DObj = object of Node2DObj
      current*, smooth*: bool
      smooth_speed*: float
      target*: NodeRef
      limit*: AnchorRef

    Camera2DRef = ref Camera2DObj

# Procs

    proc Camera2D(name: string = "Camera2D"): Camera2DRef {...}{.raises: [], tags: [].}

  Creates a new Camera2D.

  Arguments:

  - `name` is a node name.

  Examples:

      var node = Camera2D("Camera2D")

# Methods

    method changeTarget(self: Camera2DRef; target: NodeRef) {...}{.base, raises: [], tags: [].}

  Changes camera target (without camera position.)

    method changeSmoothSpeed(self: Camera2DRef; speed: float) {...}{.base, raises: [], tags: [].}

  Changes camera smooth speed.

  Arguments:

  - `speed` is a smooth speed. The closer to 0, the smoother the camera. The default is 0.1.

    method disableSmooth(self: Camera2DRef) {...}{.base, raises: [], tags: [].}

  Disables smooth mode.

    method draw(self: Camera2DRef; w, h: GLfloat) {...}{.raises: [], tags: [].}

  this method uses in the `window.nim`.

    method duplicate(self: Camera2DRef): Camera2DRef {...}{.base, raises: [], tags: [].}

  Duplicates Camera2D and create a new Camera2D object.

    method enableSmooth(self: Camera2DRef; speed: float = 0.1) {...}{.base, raises: [], tags: [].}

  Enables camera smooth mode.

  Arguments:

  - `speed` is a smooth speed. The closer to 0, the smoother the camera. The default is 0.1.

    method setCurrent(self: Camera2DRef) {...}{.base, raises: [], tags: [].}

  Changes the current camera. It also automatically disable other cameras.

    method setLimit(self: Camera2DRef; x1, y1, x2, y2: float) {...}{.base, raises: [], tags: [].}

  Change camera limit.

    method setLimit(self: Camera2DRef; limit: AnchorRef) {...}{.base, raises: [], tags: [].}

  Changes camera limit.

    method setTarget(self: Camera2DRef; target: NodeRef) {...}{.base, raises: [], tags: [].}

  Changes camera target node.