class_parallax2d.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Parallax2D.xml.
  6. .. _class_Parallax2D:
  7. Parallax2D
  8. ==========
  9. **Experimental:** This node is meant to replace :ref:`ParallaxBackground<class_ParallaxBackground>` and :ref:`ParallaxLayer<class_ParallaxLayer>`. The implementation may change in the future.
  10. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  11. A node used to create a parallax scrolling background.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A **Parallax2D** is used to create a parallax effect. It can move at a different speed relative to the camera movement using :ref:`scroll_scale<class_Parallax2D_property_scroll_scale>`. This creates an illusion of depth in a 2D game. If manual scrolling is desired, the :ref:`Camera2D<class_Camera2D>` position can be ignored with :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>`.
  16. \ **Note:** Any changes to this node's position made after it enters the scene tree will be overridden if :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` is ``false`` or :ref:`screen_offset<class_Parallax2D_property_screen_offset>` is modified.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`2D Parallax <../tutorials/2d/2d_parallax>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  27. | :ref:`Vector2<class_Vector2>` | :ref:`autoscroll<class_Parallax2D_property_autoscroll>` | ``Vector2(0, 0)`` |
  28. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`follow_viewport<class_Parallax2D_property_follow_viewport>` | ``true`` |
  30. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` | ``false`` |
  32. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`limit_begin<class_Parallax2D_property_limit_begin>` | ``Vector2(-1e+07, -1e+07)`` |
  34. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`limit_end<class_Parallax2D_property_limit_end>` | ``Vector2(1e+07, 1e+07)`` |
  36. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  37. | :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | physics_interpolation_mode | ``2`` (overrides :ref:`Node<class_Node_property_physics_interpolation_mode>`) |
  38. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  39. | :ref:`Vector2<class_Vector2>` | :ref:`repeat_size<class_Parallax2D_property_repeat_size>` | ``Vector2(0, 0)`` |
  40. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`repeat_times<class_Parallax2D_property_repeat_times>` | ``1`` |
  42. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  43. | :ref:`Vector2<class_Vector2>` | :ref:`screen_offset<class_Parallax2D_property_screen_offset>` | ``Vector2(0, 0)`` |
  44. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  45. | :ref:`Vector2<class_Vector2>` | :ref:`scroll_offset<class_Parallax2D_property_scroll_offset>` | ``Vector2(0, 0)`` |
  46. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  47. | :ref:`Vector2<class_Vector2>` | :ref:`scroll_scale<class_Parallax2D_property_scroll_scale>` | ``Vector2(1, 1)`` |
  48. +---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
  49. .. rst-class:: classref-section-separator
  50. ----
  51. .. rst-class:: classref-descriptions-group
  52. Property Descriptions
  53. ---------------------
  54. .. _class_Parallax2D_property_autoscroll:
  55. .. rst-class:: classref-property
  56. :ref:`Vector2<class_Vector2>` **autoscroll** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_autoscroll>`
  57. .. rst-class:: classref-property-setget
  58. - |void| **set_autoscroll**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  59. - :ref:`Vector2<class_Vector2>` **get_autoscroll**\ (\ )
  60. Velocity at which the offset scrolls automatically, in pixels per second.
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_Parallax2D_property_follow_viewport:
  64. .. rst-class:: classref-property
  65. :ref:`bool<class_bool>` **follow_viewport** = ``true`` :ref:`🔗<class_Parallax2D_property_follow_viewport>`
  66. .. rst-class:: classref-property-setget
  67. - |void| **set_follow_viewport**\ (\ value\: :ref:`bool<class_bool>`\ )
  68. - :ref:`bool<class_bool>` **get_follow_viewport**\ (\ )
  69. If ``true``, this **Parallax2D** is offset by the current camera's position. If the **Parallax2D** is in a :ref:`CanvasLayer<class_CanvasLayer>` separate from the current camera, it may be desired to match the value with :ref:`CanvasLayer.follow_viewport_enabled<class_CanvasLayer_property_follow_viewport_enabled>`.
  70. .. rst-class:: classref-item-separator
  71. ----
  72. .. _class_Parallax2D_property_ignore_camera_scroll:
  73. .. rst-class:: classref-property
  74. :ref:`bool<class_bool>` **ignore_camera_scroll** = ``false`` :ref:`🔗<class_Parallax2D_property_ignore_camera_scroll>`
  75. .. rst-class:: classref-property-setget
  76. - |void| **set_ignore_camera_scroll**\ (\ value\: :ref:`bool<class_bool>`\ )
  77. - :ref:`bool<class_bool>` **is_ignore_camera_scroll**\ (\ )
  78. If ``true``, **Parallax2D**'s position is not affected by the position of the camera.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_Parallax2D_property_limit_begin:
  82. .. rst-class:: classref-property
  83. :ref:`Vector2<class_Vector2>` **limit_begin** = ``Vector2(-1e+07, -1e+07)`` :ref:`🔗<class_Parallax2D_property_limit_begin>`
  84. .. rst-class:: classref-property-setget
  85. - |void| **set_limit_begin**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  86. - :ref:`Vector2<class_Vector2>` **get_limit_begin**\ (\ )
  87. Top-left limits for scrolling to begin. If the camera is outside of this limit, the **Parallax2D** stops scrolling. Must be lower than :ref:`limit_end<class_Parallax2D_property_limit_end>` minus the viewport size to work.
  88. .. rst-class:: classref-item-separator
  89. ----
  90. .. _class_Parallax2D_property_limit_end:
  91. .. rst-class:: classref-property
  92. :ref:`Vector2<class_Vector2>` **limit_end** = ``Vector2(1e+07, 1e+07)`` :ref:`🔗<class_Parallax2D_property_limit_end>`
  93. .. rst-class:: classref-property-setget
  94. - |void| **set_limit_end**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  95. - :ref:`Vector2<class_Vector2>` **get_limit_end**\ (\ )
  96. Bottom-right limits for scrolling to end. If the camera is outside of this limit, the **Parallax2D** will stop scrolling. Must be higher than :ref:`limit_begin<class_Parallax2D_property_limit_begin>` and the viewport size combined to work.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_Parallax2D_property_repeat_size:
  100. .. rst-class:: classref-property
  101. :ref:`Vector2<class_Vector2>` **repeat_size** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_repeat_size>`
  102. .. rst-class:: classref-property-setget
  103. - |void| **set_repeat_size**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  104. - :ref:`Vector2<class_Vector2>` **get_repeat_size**\ (\ )
  105. Repeats the :ref:`Texture2D<class_Texture2D>` of each of this node's children and offsets them by this value. When scrolling, the node's position loops, giving the illusion of an infinite scrolling background if the values are larger than the screen size. If an axis is set to ``0``, the :ref:`Texture2D<class_Texture2D>` will not be repeated.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_Parallax2D_property_repeat_times:
  109. .. rst-class:: classref-property
  110. :ref:`int<class_int>` **repeat_times** = ``1`` :ref:`🔗<class_Parallax2D_property_repeat_times>`
  111. .. rst-class:: classref-property-setget
  112. - |void| **set_repeat_times**\ (\ value\: :ref:`int<class_int>`\ )
  113. - :ref:`int<class_int>` **get_repeat_times**\ (\ )
  114. Overrides the amount of times the texture repeats. Each texture copy spreads evenly from the original by :ref:`repeat_size<class_Parallax2D_property_repeat_size>`. Useful for when zooming out with a camera.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_Parallax2D_property_screen_offset:
  118. .. rst-class:: classref-property
  119. :ref:`Vector2<class_Vector2>` **screen_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_screen_offset>`
  120. .. rst-class:: classref-property-setget
  121. - |void| **set_screen_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  122. - :ref:`Vector2<class_Vector2>` **get_screen_offset**\ (\ )
  123. Offset used to scroll this **Parallax2D**. This value is updated automatically unless :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` is ``true``.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_Parallax2D_property_scroll_offset:
  127. .. rst-class:: classref-property
  128. :ref:`Vector2<class_Vector2>` **scroll_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_scroll_offset>`
  129. .. rst-class:: classref-property-setget
  130. - |void| **set_scroll_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  131. - :ref:`Vector2<class_Vector2>` **get_scroll_offset**\ (\ )
  132. The **Parallax2D**'s offset. Similar to :ref:`screen_offset<class_Parallax2D_property_screen_offset>` and :ref:`Node2D.position<class_Node2D_property_position>`, but will not be overridden.
  133. \ **Note:** Values will loop if :ref:`repeat_size<class_Parallax2D_property_repeat_size>` is set higher than ``0``.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_Parallax2D_property_scroll_scale:
  137. .. rst-class:: classref-property
  138. :ref:`Vector2<class_Vector2>` **scroll_scale** = ``Vector2(1, 1)`` :ref:`🔗<class_Parallax2D_property_scroll_scale>`
  139. .. rst-class:: classref-property-setget
  140. - |void| **set_scroll_scale**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  141. - :ref:`Vector2<class_Vector2>` **get_scroll_scale**\ (\ )
  142. Multiplier to the final **Parallax2D**'s offset. Can be used to simulate distance from the camera.
  143. For example, a value of ``1`` scrolls at the same speed as the camera. A value greater than ``1`` scrolls faster, making objects appear closer. Less than ``1`` scrolls slower, making objects appear further, and a value of ``0`` stops the objects completely.
  144. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  145. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  146. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  147. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  148. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  149. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  150. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  151. .. |void| replace:: :abbr:`void (No return value.)`