Documentation
¶
Overview ¶
A hierarchy of [graphics.gd/classdb/Bone2D]s can be bound to a graphics.gd/classdb/Skeleton2D to control and animate other graphics.gd/classdb/Node2D nodes.
You can use graphics.gd/classdb/Bone2D and graphics.gd/classdb/Skeleton2D nodes to animate 2D meshes created with the graphics.gd/classdb/Polygon2D UV editor.
Each bone has a Instance.Rest transform that you can reset to with Instance.ApplyRest. These rest poses are relative to the bone's parent.
If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) ApplyRest()
- func (self Instance) AsBone2D() Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) GetAutocalculateLengthAndAngle() bool
- func (self Instance) GetBoneAngle() Angle.Radians
- func (self Instance) GetIndexInSkeleton() int
- func (self Instance) GetLength() Float.X
- func (self Instance) GetSkeletonRest() Transform2D.OriginXY
- func (self Instance) ID() ID
- func (self Instance) Rest() Transform2D.OriginXY
- func (self Instance) SetAutocalculateLengthAndAngle(auto_calculate bool)
- func (self Instance) SetBoneAngle(angle Angle.Radians)
- func (self Instance) SetLength(length Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetRest(value Transform2D.OriginXY)
- 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]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
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) ApplyRest ¶
func (self Instance) ApplyRest()
Resets the bone to the rest pose. This is equivalent to setting graphics.gd/classdb/Node2D.Instance.Transform to Instance.Rest.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) GetAutocalculateLengthAndAngle ¶
Returns whether this graphics.gd/classdb/Bone2D is going to autocalculate its length and bone angle using its first graphics.gd/classdb/Bone2D child node, if one exists. If there are no graphics.gd/classdb/Bone2D children, then it cannot autocalculate these values and will print a warning.
func (Instance) GetBoneAngle ¶
Returns the angle of the bone in the graphics.gd/classdb/Bone2D.
Note: This is different from the graphics.gd/classdb/Bone2D's rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the graphics.gd/classdb/Bone2D's graphics.gd/classdb/Node2D.Instance.Transform.
func (Instance) GetIndexInSkeleton ¶
Returns the node's index as part of the entire skeleton. See graphics.gd/classdb/Skeleton2D.
func (Instance) GetLength ¶
Returns the length of the bone in the graphics.gd/classdb/Bone2D node.
func (Instance) GetSkeletonRest ¶
func (self Instance) GetSkeletonRest() Transform2D.OriginXY
Returns the node's Instance.Rest [Transform2D.OriginXY] if it doesn't have a parent, or its rest pose relative to its parent.
func (Instance) Rest ¶
func (self Instance) Rest() Transform2D.OriginXY
func (Instance) SetAutocalculateLengthAndAngle ¶
When set to true, the graphics.gd/classdb/Bone2D node will attempt to automatically calculate the bone angle and length using the first child graphics.gd/classdb/Bone2D node, if one exists. If none exist, the graphics.gd/classdb/Bone2D cannot automatically calculate these values and will print a warning.
func (Instance) SetBoneAngle ¶
Sets the bone angle for the graphics.gd/classdb/Bone2D. This is typically set to the rotation from the graphics.gd/classdb/Bone2D to a child graphics.gd/classdb/Bone2D node.
Note: This is different from the graphics.gd/classdb/Bone2D's rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the graphics.gd/classdb/Bone2D's graphics.gd/classdb/Node2D.Instance.Transform.
func (Instance) SetLength ¶
Sets the length of the bone in the graphics.gd/classdb/Bone2D.
func (Instance) SetRest ¶
func (self Instance) SetRest(value Transform2D.OriginXY)