Shape2D

package
v0.0.0-...-ad02d68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 27 Imported by: 0

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

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 Any

type Any interface {
	gd.IsClass
	AsShape2D() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsShape2D

func (self *Extension[T]) AsShape2D() Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Shape2D

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 New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsShape2D

func (self Instance) AsShape2D() Instance

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 (self Instance) CustomSolverBias() Float.X

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.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) SetCustomSolverBias

func (self Instance) SetCustomSolverBias(value Float.X)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL