# nodesnim/nodes2d/kinematic_body2d

Dark Mode

Search:
Group by:

This uses for create hero with physics.

# Imports

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

# Types

    KinematicBody2DObj = object of Node2DObj
      has_collision*: bool
      collision_node*: CollisionShape2DRef

    KinematicBody2DRef = ref KinematicBody2DObj

# Procs

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

  Creates a new KinematicBody2D.

  Arguments:

  - `name` is a node name.

  Examples:

      var node = KinematicBody2D("KinematicBody2D")

# Methods

    method addChild(self: KinematicBody2DRef; other: CollisionShape2DRef) {...}{.base,
        raises: [], tags: [].}

  Adss collision to the KinematicBody2D. This method should be called one time.

    method getCollideCount(self: KinematicBody2DRef): int {...}{.base, raises: [Exception],
        tags: [RootEffect].}

  Checks collision count.

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

  this method uses in the `window.nim`.

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

  Duplicates KinematicBody2D and create a new KinematicBody2D pointer.

    method isCollide(self: KinematicBody2DRef): bool {...}{.base, raises: [Exception],
        tags: [RootEffect].}

  Checks any collision and return `true`, when collide with any collision shape.

    method moveAndCollide(self: KinematicBody2DRef; vel: Vector2Ref) {...}{.base,
        raises: [Exception], tags: [RootEffect].}

  Moves and checks collision

  Arguments:

  - `vel` is a velocity vector.