class_bone2d.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Bone2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Bone2D:
  6. Bone2D
  7. ======
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Joint used with :ref:`Skeleton2D<class_Skeleton2D>` to control and animate other nodes.
  13. Properties
  14. ----------
  15. +---------------------------------------+-------------------------------------------------------------+
  16. | :ref:`float<class_float>` | :ref:`default_length<class_Bone2D_property_default_length>` |
  17. +---------------------------------------+-------------------------------------------------------------+
  18. | :ref:`Transform2D<class_Transform2D>` | :ref:`rest<class_Bone2D_property_rest>` |
  19. +---------------------------------------+-------------------------------------------------------------+
  20. Methods
  21. -------
  22. +---------------------------------------+-------------------------------------------------------------------------------------------+
  23. | void | :ref:`apply_rest<class_Bone2D_method_apply_rest>` **(** **)** |
  24. +---------------------------------------+-------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`get_index_in_skeleton<class_Bone2D_method_get_index_in_skeleton>` **(** **)** const |
  26. +---------------------------------------+-------------------------------------------------------------------------------------------+
  27. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_skeleton_rest<class_Bone2D_method_get_skeleton_rest>` **(** **)** const |
  28. +---------------------------------------+-------------------------------------------------------------------------------------------+
  29. Description
  30. -----------
  31. Use a hierarchy of ``Bone2D`` bound to a :ref:`Skeleton2D<class_Skeleton2D>` to control, and animate other :ref:`Node2D<class_Node2D>` nodes.
  32. You can use ``Bone2D`` and ``Skeleton2D`` nodes to animate 2D meshes created with the Polygon 2D UV editor.
  33. Each bone has a :ref:`rest<class_Bone2D_property_rest>` transform that you can reset to with :ref:`apply_rest<class_Bone2D_method_apply_rest>`. These rest poses are relative to the bone's parent.
  34. 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.
  35. Property Descriptions
  36. ---------------------
  37. .. _class_Bone2D_property_default_length:
  38. - :ref:`float<class_float>` **default_length**
  39. +----------+---------------------------+
  40. | *Setter* | set_default_length(value) |
  41. +----------+---------------------------+
  42. | *Getter* | get_default_length() |
  43. +----------+---------------------------+
  44. Length of the bone's representation drawn in the editor's viewport in pixels.
  45. ----
  46. .. _class_Bone2D_property_rest:
  47. - :ref:`Transform2D<class_Transform2D>` **rest**
  48. +----------+-----------------+
  49. | *Setter* | set_rest(value) |
  50. +----------+-----------------+
  51. | *Getter* | get_rest() |
  52. +----------+-----------------+
  53. Rest transform of the bone. You can reset the node's transforms to this value using :ref:`apply_rest<class_Bone2D_method_apply_rest>`.
  54. Method Descriptions
  55. -------------------
  56. .. _class_Bone2D_method_apply_rest:
  57. - void **apply_rest** **(** **)**
  58. Stores the node's current transforms in :ref:`rest<class_Bone2D_property_rest>`.
  59. ----
  60. .. _class_Bone2D_method_get_index_in_skeleton:
  61. - :ref:`int<class_int>` **get_index_in_skeleton** **(** **)** const
  62. Returns the node's index as part of the entire skeleton. See :ref:`Skeleton2D<class_Skeleton2D>`.
  63. ----
  64. .. _class_Bone2D_method_get_skeleton_rest:
  65. - :ref:`Transform2D<class_Transform2D>` **get_skeleton_rest** **(** **)** const
  66. Returns the node's :ref:`rest<class_Bone2D_property_rest>` ``Transform2D`` if it doesn't have a parent, or its rest pose relative to its parent.