Bone2D
A joint used with Skeleton2D
to control and animate other nodes.
class Bone2D
A hierarchy of Bone2D
s can be bound to a Skeleton2D
to control and animate other Node2D
nodes.
You can use Bone2D
and Skeleton2D
nodes to animate 2D meshes created with the Polygon2D
UV editor.
Each bone has a rest
transform that you can reset to with 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.
Superclasses
class Node2D
A 2D game object, inherited by all 2D-related nodes. Has a position, rotation, scale, and Z index.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var rest: Transform2D
Rest transform of the bone. You can reset the node’s transforms to this value using
applyRest
.func applyRest(
) Stores the node’s current transforms in
rest
.func getAutocalculateLengthAndAngle(
) -> Bool Returns whether this
Bone2D
is going to autocalculate its length and bone angle using its firstBone2D
child node, if one exists. If there are noBone2D
children, then it cannot autocalculate these values and will print a warning.func getBoneAngle(
) -> Double Returns the angle of the bone in the
Bone2D
.func getIndexInSkeleton(
) -> Int32 Returns the node’s index as part of the entire skeleton. See
Skeleton2D
.func getLength(
) -> Double Returns the length of the bone in the
Bone2D
node.func getSkeletonRest(
) -> Transform2D Returns the node’s
rest
Transform2D
if it doesn’t have a parent, or its rest pose relative to its parent.func setAutocalculateLengthAndAngle(autoCalculate: Bool
) When set to
true
, theBone2D
node will attempt to automatically calculate the bone angle and length using the first childBone2D
node, if one exists. If none exist, theBone2D
cannot automatically calculate these values and will print a warning.func setBoneAngle(Double
) Sets the bone angle for the
Bone2D
. This is typically set to the rotation from theBone2D
to a childBone2D
node.func setLength(Double
) Sets the length of the bone in the
Bone2D
.