class_parallaxlayer.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/ParallaxLayer.xml.
  6. .. _class_ParallaxLayer:
  7. ParallaxLayer
  8. =============
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A parallax scrolling layer to be used with :ref:`ParallaxBackground<class_ParallaxBackground>`.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A ParallaxLayer must be the child of a :ref:`ParallaxBackground<class_ParallaxBackground>` node. Each ParallaxLayer can be set to move at different speeds relative to the camera movement or the :ref:`ParallaxBackground.scroll_offset<class_ParallaxBackground_property_scroll_offset>` value.
  15. This node's children will be affected by its scroll offset.
  16. \ **Note:** Any changes to this node's position and scale made after it enters the scene will be ignored.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +-------------------------------+------------------------------------------------------------------------+-------------------+
  23. | :ref:`Vector2<class_Vector2>` | :ref:`motion_mirroring<class_ParallaxLayer_property_motion_mirroring>` | ``Vector2(0, 0)`` |
  24. +-------------------------------+------------------------------------------------------------------------+-------------------+
  25. | :ref:`Vector2<class_Vector2>` | :ref:`motion_offset<class_ParallaxLayer_property_motion_offset>` | ``Vector2(0, 0)`` |
  26. +-------------------------------+------------------------------------------------------------------------+-------------------+
  27. | :ref:`Vector2<class_Vector2>` | :ref:`motion_scale<class_ParallaxLayer_property_motion_scale>` | ``Vector2(1, 1)`` |
  28. +-------------------------------+------------------------------------------------------------------------+-------------------+
  29. .. rst-class:: classref-section-separator
  30. ----
  31. .. rst-class:: classref-descriptions-group
  32. Property Descriptions
  33. ---------------------
  34. .. _class_ParallaxLayer_property_motion_mirroring:
  35. .. rst-class:: classref-property
  36. :ref:`Vector2<class_Vector2>` **motion_mirroring** = ``Vector2(0, 0)``
  37. .. rst-class:: classref-property-setget
  38. - void **set_mirroring** **(** :ref:`Vector2<class_Vector2>` value **)**
  39. - :ref:`Vector2<class_Vector2>` **get_mirroring** **(** **)**
  40. The interval, in pixels, at which the **ParallaxLayer** is drawn repeatedly. Useful for creating an infinitely scrolling background. If an axis is set to ``0``, the **ParallaxLayer** will be drawn only once along that direction.
  41. \ **Note:** If you want the repetition to pixel-perfect match a :ref:`Texture2D<class_Texture2D>` displayed by a child node, you should account for any scale applied to the texture when defining this interval. For example, if you use a child :ref:`Sprite2D<class_Sprite2D>` scaled to ``0.5`` to display a 600x600 texture, and want this sprite to be repeated continuously horizontally, you should set the mirroring to ``Vector2(300, 0)``.
  42. \ **Note:** If the length of the viewport axis is bigger than twice the repeated axis size, it will not repeat infinitely, as the parallax layer only draws 2 instances of the layer at any given time. The visibility window is calculated from the parent :ref:`ParallaxBackground<class_ParallaxBackground>`'s position, not the layer's own position. So, if you use mirroring, **do not** change the **ParallaxLayer** position relative to its parent. Instead, if you need to adjust the background's position, set the :ref:`CanvasLayer.offset<class_CanvasLayer_property_offset>` property in the parent :ref:`ParallaxBackground<class_ParallaxBackground>`.
  43. \ **Note:** Despite the name, the layer will not be mirrored, it will only be repeated.
  44. .. rst-class:: classref-item-separator
  45. ----
  46. .. _class_ParallaxLayer_property_motion_offset:
  47. .. rst-class:: classref-property
  48. :ref:`Vector2<class_Vector2>` **motion_offset** = ``Vector2(0, 0)``
  49. .. rst-class:: classref-property-setget
  50. - void **set_motion_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  51. - :ref:`Vector2<class_Vector2>` **get_motion_offset** **(** **)**
  52. The ParallaxLayer's offset relative to the parent ParallaxBackground's :ref:`ParallaxBackground.scroll_offset<class_ParallaxBackground_property_scroll_offset>`.
  53. .. rst-class:: classref-item-separator
  54. ----
  55. .. _class_ParallaxLayer_property_motion_scale:
  56. .. rst-class:: classref-property
  57. :ref:`Vector2<class_Vector2>` **motion_scale** = ``Vector2(1, 1)``
  58. .. rst-class:: classref-property-setget
  59. - void **set_motion_scale** **(** :ref:`Vector2<class_Vector2>` value **)**
  60. - :ref:`Vector2<class_Vector2>` **get_motion_scale** **(** **)**
  61. Multiplies the ParallaxLayer's motion. If an axis is set to ``0``, it will not scroll.
  62. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  63. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  64. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  65. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  66. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  67. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  68. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`