Bone2D

package
v0.0.0-...-0d6c339 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 26 Imported by: 0

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

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
	AsBone2D() 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]) AsBone2D

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

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

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

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.Bone2D

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) 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) AsBone2D

func (self Instance) AsBone2D() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

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

func (Instance) GetAutocalculateLengthAndAngle

func (self Instance) GetAutocalculateLengthAndAngle() bool

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

func (self Instance) GetBoneAngle() Angle.Radians

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

func (self Instance) GetIndexInSkeleton() int

Returns the node's index as part of the entire skeleton. See graphics.gd/classdb/Skeleton2D.

func (Instance) GetLength

func (self Instance) GetLength() Float.X

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) ID

func (self Instance) ID() ID

func (Instance) Rest

func (self Instance) Rest() Transform2D.OriginXY

func (Instance) SetAutocalculateLengthAndAngle

func (self Instance) SetAutocalculateLengthAndAngle(auto_calculate bool)

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

func (self Instance) SetBoneAngle(angle Angle.Radians)

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

func (self Instance) SetLength(length Float.X)

Sets the length of the bone in the graphics.gd/classdb/Bone2D.

func (*Instance) SetObject

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

func (Instance) SetRest

func (self Instance) SetRest(value Transform2D.OriginXY)

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