Documentation
¶
Overview ¶
Package Shape2D provides methods for working with Shape2D object instances.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AsShape2D() Instance
- func (self Instance) Collide(local_xform Transform2D.OriginXY, with_shape Instance, ...) bool
- func (self Instance) CollideAndGetContacts(local_xform Transform2D.OriginXY, with_shape Instance, ...) []Vector2.XY
- func (self Instance) CollideWithMotion(local_xform Transform2D.OriginXY, local_motion Vector2.XY, with_shape Instance, ...) bool
- func (self Instance) CollideWithMotionAndGetContacts(local_xform Transform2D.OriginXY, local_motion Vector2.XY, with_shape Instance, ...) []Vector2.XY
- func (self Instance) CustomSolverBias() Float.X
- func (self Instance) Draw(canvas_item RID.CanvasItem, color Color.RGBA)
- func (self Instance) GetRect() Rect2.PositionSize
- func (self Instance) ID() ID
- func (self Instance) SetCustomSolverBias(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Abstract base class for all 2D shapes, intended for use in physics. [b]Performance:[/b] Primitive shapes, especially [CircleShape2D], are fast to check collisions against. [ConvexPolygonShape2D] is slower, and [ConcavePolygonShape2D] is the slowest.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) Collide ¶
func (self Instance) Collide(local_xform Transform2D.OriginXY, with_shape Instance, shape_xform Transform2D.OriginXY) bool
Returns [code]true[/code] if this shape is colliding with another. This method needs the transformation matrix for this shape ([param local_xform]), the shape to check collisions with ([param with_shape]), and the transformation matrix of that shape ([param shape_xform]).
func (Instance) CollideAndGetContacts ¶
func (self Instance) CollideAndGetContacts(local_xform Transform2D.OriginXY, with_shape Instance, shape_xform Transform2D.OriginXY) []Vector2.XY
Returns a list of contact point pairs where this shape touches another. If there are no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of [param with_shape]. A collision pair A, B can be used to calculate the collision normal with [code](B - A).normalized()[/code], and the collision depth with [code](B - A).length()[/code]. This information is typically used to separate shapes, particularly in collision solvers. This method needs the transformation matrix for this shape ([param local_xform]), the shape to check collisions with ([param with_shape]), and the transformation matrix of that shape ([param shape_xform]).
func (Instance) CollideWithMotion ¶
func (self Instance) CollideWithMotion(local_xform Transform2D.OriginXY, local_motion Vector2.XY, with_shape Instance, shape_xform Transform2D.OriginXY, shape_motion Vector2.XY) bool
Returns whether this shape would collide with another, if a given movement was applied. This method needs the transformation matrix for this shape ([param local_xform]), the movement to test on this shape ([param local_motion]), the shape to check collisions with ([param with_shape]), the transformation matrix of that shape ([param shape_xform]), and the movement to test onto the other object ([param shape_motion]).
func (Instance) CollideWithMotionAndGetContacts ¶
func (self Instance) CollideWithMotionAndGetContacts(local_xform Transform2D.OriginXY, local_motion Vector2.XY, with_shape Instance, shape_xform Transform2D.OriginXY, shape_motion Vector2.XY) []Vector2.XY
Returns a list of contact point pairs where this shape would touch another, if a given movement was applied. If there would be no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of [param with_shape]. A collision pair A, B can be used to calculate the collision normal with [code](B - A).normalized()[/code], and the collision depth with [code](B - A).length()[/code]. This information is typically used to separate shapes, particularly in collision solvers. This method needs the transformation matrix for this shape ([param local_xform]), the movement to test on this shape ([param local_motion]), the shape to check collisions with ([param with_shape]), the transformation matrix of that shape ([param shape_xform]), and the movement to test onto the other object ([param shape_motion]).
func (Instance) CustomSolverBias ¶
func (Instance) Draw ¶
func (self Instance) Draw(canvas_item RID.CanvasItem, color Color.RGBA)
Draws a solid shape onto a [CanvasItem] with the [RenderingServer] API filled with the specified [param color]. The exact drawing method is specific for each shape and cannot be configured.
func (Instance) GetRect ¶
func (self Instance) GetRect() Rect2.PositionSize
Returns a [Rect2] representing the shapes boundary.