Skip to content
0.2.0-dev Download ZIP
80 lines ·3.8 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="Bone2D" inherits="Node2D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A joint used with [Skeleton2D] to control and animate other nodes.
5 </brief_description>
6 <description>
7 A hierarchy of [Bone2D]s can be bound to a [Skeleton2D] to control and animate other [Node2D] nodes.
8 You can use [Bone2D] and [Skeleton2D] nodes to animate 2D meshes created with the [Polygon2D] UV editor.
9 Each bone has a [member rest] transform that you can reset to with [method apply_rest]. These rest poses are relative to the bone's parent.
10 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.
11 </description>
12 <tutorials>
13 </tutorials>
14 <methods>
15 <method name="apply_rest">
16 <return type="void" />
17 <description>
18 Resets the bone to the rest pose. This is equivalent to setting [member Node2D.transform] to [member rest].
19 </description>
20 </method>
21 <method name="get_autocalculate_length_and_angle" qualifiers="const">
22 <return type="bool" />
23 <description>
24 Returns whether this [Bone2D] is going to autocalculate its length and bone angle using its first [Bone2D] child node, if one exists. If there are no [Bone2D] children, then it cannot autocalculate these values and will print a warning.
25 </description>
26 </method>
27 <method name="get_bone_angle" qualifiers="const">
28 <return type="float" />
29 <description>
30 Returns the angle of the bone in the [Bone2D].
31 [b]Note:[/b] This is different from the [Bone2D]'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the [Bone2D]'s [member Node2D.transform].
32 </description>
33 </method>
34 <method name="get_index_in_skeleton" qualifiers="const">
35 <return type="int" />
36 <description>
37 Returns the node's index as part of the entire skeleton. See [Skeleton2D].
38 </description>
39 </method>
40 <method name="get_length" qualifiers="const">
41 <return type="float" />
42 <description>
43 Returns the length of the bone in the [Bone2D] node.
44 </description>
45 </method>
46 <method name="get_skeleton_rest" qualifiers="const">
47 <return type="Transform2D" />
48 <description>
49 Returns the node's [member rest] [Transform2D] if it doesn't have a parent, or its rest pose relative to its parent.
50 </description>
51 </method>
52 <method name="set_autocalculate_length_and_angle">
53 <return type="void" />
54 <param index="0" name="auto_calculate" type="bool" />
55 <description>
56 When set to [code]true[/code], the [Bone2D] node will attempt to automatically calculate the bone angle and length using the first child [Bone2D] node, if one exists. If none exist, the [Bone2D] cannot automatically calculate these values and will print a warning.
57 </description>
58 </method>
59 <method name="set_bone_angle">
60 <return type="void" />
61 <param index="0" name="angle" type="float" />
62 <description>
63 Sets the bone angle for the [Bone2D]. This is typically set to the rotation from the [Bone2D] to a child [Bone2D] node.
64 [b]Note:[/b] This is different from the [Bone2D]'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the [Bone2D]'s [member Node2D.transform].
65 </description>
66 </method>
67 <method name="set_length">
68 <return type="void" />
69 <param index="0" name="length" type="float" />
70 <description>
71 Sets the length of the bone in the [Bone2D].
72 </description>
73 </method>
74 </methods>
75 <members>
76 <member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D(0, 0, 0, 0, 0, 0)">
77 Rest transform of the bone. You can reset the node's transforms to this value using [method apply_rest].
78 </member>
79 </members>
80</class>