class_pathfollow2d.rst 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_PathFollow2D:
  4. PathFollow2D
  5. ============
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Point sampler for a :ref:`Path2D<class_path2d>`.
  11. Member Functions
  12. ----------------
  13. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`bool<class_bool>` | :ref:`get_cubic_interpolation<class_PathFollow2D_get_cubic_interpolation>` **(** **)** const |
  15. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`float<class_float>` | :ref:`get_h_offset<class_PathFollow2D_get_h_offset>` **(** **)** const |
  17. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`get_offset<class_PathFollow2D_get_offset>` **(** **)** const |
  19. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`get_unit_offset<class_PathFollow2D_get_unit_offset>` **(** **)** const |
  21. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`float<class_float>` | :ref:`get_v_offset<class_PathFollow2D_get_v_offset>` **(** **)** const |
  23. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`has_loop<class_PathFollow2D_has_loop>` **(** **)** const |
  25. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_rotating<class_PathFollow2D_is_rotating>` **(** **)** const |
  27. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_cubic_interpolation<class_PathFollow2D_set_cubic_interpolation>` **(** :ref:`bool<class_bool>` enable **)** |
  29. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_h_offset<class_PathFollow2D_set_h_offset>` **(** :ref:`float<class_float>` h_offset **)** |
  31. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_loop<class_PathFollow2D_set_loop>` **(** :ref:`bool<class_bool>` loop **)** |
  33. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_offset<class_PathFollow2D_set_offset>` **(** :ref:`float<class_float>` offset **)** |
  35. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_rotate<class_PathFollow2D_set_rotate>` **(** :ref:`bool<class_bool>` enable **)** |
  37. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_unit_offset<class_PathFollow2D_set_unit_offset>` **(** :ref:`float<class_float>` unit_offset **)** |
  39. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_v_offset<class_PathFollow2D_set_v_offset>` **(** :ref:`float<class_float>` v_offset **)** |
  41. +----------------------------+-------------------------------------------------------------------------------------------------------------------------+
  42. Description
  43. -----------
  44. This node takes its parent :ref:`Path2D<class_path2d>`, and returns the coordinates of a point within it, given a distance from the first vertex.
  45. It is useful for making other nodes follow a path, without coding the movement pattern. For that, the nodes must be descendants of this node. Then, when setting an offset in this node, the descendant nodes will move accordingly.
  46. Member Function Description
  47. ---------------------------
  48. .. _class_PathFollow2D_get_cubic_interpolation:
  49. - :ref:`bool<class_bool>` **get_cubic_interpolation** **(** **)** const
  50. This method returns whether the position between two cached points (see :ref:`set_cubic_interpolation<class_PathFollow2D_set_cubic_interpolation>`) is interpolated linearly, or cubicly.
  51. .. _class_PathFollow2D_get_h_offset:
  52. - :ref:`float<class_float>` **get_h_offset** **(** **)** const
  53. Returns the horizontal displacement this node has from its parent :ref:`Path2D<class_path2d>`.
  54. .. _class_PathFollow2D_get_offset:
  55. - :ref:`float<class_float>` **get_offset** **(** **)** const
  56. Returns the distance along the path in pixels.
  57. .. _class_PathFollow2D_get_unit_offset:
  58. - :ref:`float<class_float>` **get_unit_offset** **(** **)** const
  59. Returns the distance along the path as a number in the range 0.0 (for the first vertex) to 1.0 (for the last).
  60. .. _class_PathFollow2D_get_v_offset:
  61. - :ref:`float<class_float>` **get_v_offset** **(** **)** const
  62. Returns the vertical displacement this node has from its parent :ref:`Path2D<class_path2d>`.
  63. .. _class_PathFollow2D_has_loop:
  64. - :ref:`bool<class_bool>` **has_loop** **(** **)** const
  65. Returns whether this node wraps its offsets around, or truncates them to the path ends.
  66. .. _class_PathFollow2D_is_rotating:
  67. - :ref:`bool<class_bool>` **is_rotating** **(** **)** const
  68. Returns whether this node rotates to follow the path.
  69. .. _class_PathFollow2D_set_cubic_interpolation:
  70. - void **set_cubic_interpolation** **(** :ref:`bool<class_bool>` enable **)**
  71. The points along the :ref:`Curve2D<class_curve2d>` of the :ref:`Path2D<class_path2d>` are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough.
  72. There are two answers to this problem: Either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations.
  73. This method controls whether the position between two cached points is interpolated linearly, or cubicly.
  74. .. _class_PathFollow2D_set_h_offset:
  75. - void **set_h_offset** **(** :ref:`float<class_float>` h_offset **)**
  76. Moves this node horizontally. As this node's position will be set every time its offset is set, this allows many PathFollow2D to share the same curve (and thus the same movement pattern), yet not return the same position for a given path offset.
  77. A similar effect may be achieved moving this node's descendants.
  78. .. _class_PathFollow2D_set_loop:
  79. - void **set_loop** **(** :ref:`bool<class_bool>` loop **)**
  80. If set, any offset outside the path's length (whether set by :ref:`set_offset<class_PathFollow2D_set_offset>` or :ref:`set_unit_offset<class_PathFollow2D_set_unit_offset>` will wrap around, instead of stopping at the ends. Set it for cyclic paths.
  81. .. _class_PathFollow2D_set_offset:
  82. - void **set_offset** **(** :ref:`float<class_float>` offset **)**
  83. Sets the distance from the first vertex, measured in pixels along the path. This sets this node's position to a point within the path.
  84. .. _class_PathFollow2D_set_rotate:
  85. - void **set_rotate** **(** :ref:`bool<class_bool>` enable **)**
  86. If set, this node rotates to follow the path, making its descendants rotate.
  87. .. _class_PathFollow2D_set_unit_offset:
  88. - void **set_unit_offset** **(** :ref:`float<class_float>` unit_offset **)**
  89. Sets the distance from the first vertex, considering 0.0 as the first vertex and 1.0 as the last. This is just another way of expressing the offset within the path, as the offset supplied is multiplied internally by the path's length.
  90. .. _class_PathFollow2D_set_v_offset:
  91. - void **set_v_offset** **(** :ref:`float<class_float>` v_offset **)**
  92. Moves the PathFollow2D vertically, for the same reasons of :ref:`set_h_offset<class_PathFollow2D_set_h_offset>`.