It provides collision shapes.
Types
CollisionShape2DObj = object of Node2DObj disable*: bool x1*, y1*, radius*: float polygon*: seq[Vector2Obj] shape_type*: CollisionShape2DType
CollisionShape2DRef = ref CollisionShape2DObj
Procs
proc CollisionShape2D(name: string = "CollisionShape2D"): CollisionShape2DRef {...}{. raises: [], tags: [].}
-
Creates a new CollisionShape2D.
Arguments:
- name is a node name.
Example:
var node = CollisionShape2D("CollisionShape2D")
Methods
method setShapeTypeRect(self: CollisionShape2DRef) {...}{.base, raises: [], tags: [].}
- Changes shape type to circle.
method setShapeTypeCircle(self: CollisionShape2DRef; cx, cy, radius: float) {...}{. base, raises: [], tags: [].}
-
Changes shape type to rectangle.
Arguments:
- cx is a center circle position at X axis.
- cy is a center circle position at Y axis.
- radius is a circle radius.
method setShapeTypePolygon(self: CollisionShape2DRef; positions: varargs[Vector2Obj]) {...}{.base, raises: [], tags: [].}
-
Changes shape type to polygon.
Arguments:
- positions is a varargs of polygon positions. Should be more than 2.
method duplicate(self: CollisionShape2DRef): CollisionShape2DRef {...}{.base, raises: [], tags: [].}
- Duplicates CollisionShape2D object and create a new CollisionShape2D.
method isCollide(self: CollisionShape2DRef; x, y: float): bool {...}{.base, raises: [], tags: [].}
-
Checks collision with point.
Arguments:
- x is a point position at X axis.
- y is a point position at Y axis.
method isCollide(self: CollisionShape2DRef; vec2: Vector2Obj): bool {...}{.base, raises: [], tags: [].}
- Checks collision with point.
method isCollide(self, other: CollisionShape2DRef): bool {...}{.base, raises: [], tags: [].}
- Checks collision with other CollisionShape2D object.