Documentation
¶
Overview ¶
Abstract base class for all 2D shapes, intended for use in physics. Performance: Primitive shapes, especially [CircleShape2D], are fast to check collisions against. [ConvexPolygonShape2D] is slower, and [ConcavePolygonShape2D] is the slowest.
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) 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 ¶
Instance of the class with convieniently typed arguments and results.
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 true if this shape is colliding with another. This method needs the transformation matrix for this shape ('local_xform'), the shape to check collisions with ('with_shape'), and the transformation matrix of that shape ('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 'with_shape'. A collision pair A, B can be used to calculate the collision normal with (B - A).normalized(), and the collision depth with (B - A).length(). This information is typically used to separate shapes, particularly in collision solvers. This method needs the transformation matrix for this shape ('local_xform'), the shape to check collisions with ('with_shape'), and the transformation matrix of that shape ('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 ('local_xform'), the movement to test on this shape ('local_motion'), the shape to check collisions with ('with_shape'), the transformation matrix of that shape ('shape_xform'), and the movement to test onto the other object ('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 'with_shape'. A collision pair A, B can be used to calculate the collision normal with (B - A).normalized(), and the collision depth with (B - A).length(). This information is typically used to separate shapes, particularly in collision solvers. This method needs the transformation matrix for this shape ('local_xform'), the movement to test on this shape ('local_motion'), the shape to check collisions with ('with_shape'), the transformation matrix of that shape ('shape_xform'), and the movement to test onto the other object ('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 '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.